/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

// @generated by gentest/gentest.rb from gentest/fixtures/YGGapTest.html

using System;
using NUnit.Framework;

namespace Facebook.Yoga
{
    [TestFixture]
    public class YGGapTest
    {
        [Test]
        public void Test_column_gap_flexible()
        {
            YogaConfig config = new YogaConfig();
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.FixAbsoluteTrailingColumnMargin, true);

            YogaNode root = new YogaNode(config);
            root.FlexDirection = YogaFlexDirection.Row;
            root.Width = 80;
            root.Height = 100;
            root.ColumnGap = 10;
            root.RowGap = 20;

            YogaNode root_child0 = new YogaNode(config);
            root_child0.FlexGrow = 1;
            root_child0.FlexShrink = 1;
            root_child0.FlexBasis = 0.Percent();
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);
            root_child1.FlexGrow = 1;
            root_child1.FlexShrink = 1;
            root_child1.FlexBasis = 0.Percent();
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);
            root_child2.FlexGrow = 1;
            root_child2.FlexShrink = 1;
            root_child2.FlexBasis = 0.Percent();
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(80f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(30f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(60f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(80f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(60f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(30f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);
        }

        [Test]
        public void Test_column_gap_inflexible()
        {
            YogaConfig config = new YogaConfig();
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.FixAbsoluteTrailingColumnMargin, true);

            YogaNode root = new YogaNode(config);
            root.FlexDirection = YogaFlexDirection.Row;
            root.Width = 80;
            root.Height = 100;
            root.ColumnGap = 10;

            YogaNode root_child0 = new YogaNode(config);
            root_child0.Width = 20;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);
            root_child1.Width = 20;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);
            root_child2.Width = 20;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(80f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(30f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(60f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(80f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(60f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(30f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);
        }

        [Test]
        public void Test_column_gap_mixed_flexible()
        {
            YogaConfig config = new YogaConfig();
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.FixAbsoluteTrailingColumnMargin, true);

            YogaNode root = new YogaNode(config);
            root.FlexDirection = YogaFlexDirection.Row;
            root.Width = 80;
            root.Height = 100;
            root.ColumnGap = 10;

            YogaNode root_child0 = new YogaNode(config);
            root_child0.Width = 20;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);
            root_child1.FlexGrow = 1;
            root_child1.FlexShrink = 1;
            root_child1.FlexBasis = 0.Percent();
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);
            root_child2.Width = 20;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(80f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(30f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(60f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(80f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(60f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(30f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);
        }

        [Test]
        public void Test_column_gap_child_margins()
        {
            YogaConfig config = new YogaConfig();
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.FixAbsoluteTrailingColumnMargin, true);

            YogaNode root = new YogaNode(config);
            root.FlexDirection = YogaFlexDirection.Row;
            root.Width = 80;
            root.Height = 100;
            root.ColumnGap = 10;

            YogaNode root_child0 = new YogaNode(config);
            root_child0.FlexGrow = 1;
            root_child0.FlexShrink = 1;
            root_child0.FlexBasis = 0.Percent();
            root_child0.MarginLeft = 2;
            root_child0.MarginRight = 2;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);
            root_child1.FlexGrow = 1;
            root_child1.FlexShrink = 1;
            root_child1.FlexBasis = 0.Percent();
            root_child1.MarginLeft = 10;
            root_child1.MarginRight = 10;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);
            root_child2.FlexGrow = 1;
            root_child2.FlexShrink = 1;
            root_child2.FlexBasis = 0.Percent();
            root_child2.MarginLeft = 15;
            root_child2.MarginRight = 15;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(80f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(2f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(2f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(26f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(2f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(63f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(2f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(80f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(76f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(2f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(52f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(2f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(15f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(2f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);
        }

        [Test]
        public void Test_column_row_gap_wrapping()
        {
            YogaConfig config = new YogaConfig();
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.FixAbsoluteTrailingColumnMargin, true);

            YogaNode root = new YogaNode(config);
            root.FlexDirection = YogaFlexDirection.Row;
            root.Wrap = YogaWrap.Wrap;
            root.Width = 80;
            root.ColumnGap = 10;
            root.RowGap = 20;

            YogaNode root_child0 = new YogaNode(config);
            root_child0.Width = 20;
            root_child0.Height = 20;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);
            root_child1.Width = 20;
            root_child1.Height = 20;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);
            root_child2.Width = 20;
            root_child2.Height = 20;
            root.Insert(2, root_child2);

            YogaNode root_child3 = new YogaNode(config);
            root_child3.Width = 20;
            root_child3.Height = 20;
            root.Insert(3, root_child3);

            YogaNode root_child4 = new YogaNode(config);
            root_child4.Width = 20;
            root_child4.Height = 20;
            root.Insert(4, root_child4);

            YogaNode root_child5 = new YogaNode(config);
            root_child5.Width = 20;
            root_child5.Height = 20;
            root.Insert(5, root_child5);

            YogaNode root_child6 = new YogaNode(config);
            root_child6.Width = 20;
            root_child6.Height = 20;
            root.Insert(6, root_child6);

            YogaNode root_child7 = new YogaNode(config);
            root_child7.Width = 20;
            root_child7.Height = 20;
            root.Insert(7, root_child7);

            YogaNode root_child8 = new YogaNode(config);
            root_child8.Width = 20;
            root_child8.Height = 20;
            root.Insert(8, root_child8);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(80f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(20f, root_child0.LayoutHeight);

            Assert.AreEqual(30f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(20f, root_child1.LayoutHeight);

            Assert.AreEqual(60f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(20f, root_child2.LayoutHeight);

            Assert.AreEqual(0f, root_child3.LayoutX);
            Assert.AreEqual(40f, root_child3.LayoutY);
            Assert.AreEqual(20f, root_child3.LayoutWidth);
            Assert.AreEqual(20f, root_child3.LayoutHeight);

            Assert.AreEqual(30f, root_child4.LayoutX);
            Assert.AreEqual(40f, root_child4.LayoutY);
            Assert.AreEqual(20f, root_child4.LayoutWidth);
            Assert.AreEqual(20f, root_child4.LayoutHeight);

            Assert.AreEqual(60f, root_child5.LayoutX);
            Assert.AreEqual(40f, root_child5.LayoutY);
            Assert.AreEqual(20f, root_child5.LayoutWidth);
            Assert.AreEqual(20f, root_child5.LayoutHeight);

            Assert.AreEqual(0f, root_child6.LayoutX);
            Assert.AreEqual(80f, root_child6.LayoutY);
            Assert.AreEqual(20f, root_child6.LayoutWidth);
            Assert.AreEqual(20f, root_child6.LayoutHeight);

            Assert.AreEqual(30f, root_child7.LayoutX);
            Assert.AreEqual(80f, root_child7.LayoutY);
            Assert.AreEqual(20f, root_child7.LayoutWidth);
            Assert.AreEqual(20f, root_child7.LayoutHeight);

            Assert.AreEqual(60f, root_child8.LayoutX);
            Assert.AreEqual(80f, root_child8.LayoutY);
            Assert.AreEqual(20f, root_child8.LayoutWidth);
            Assert.AreEqual(20f, root_child8.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(80f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(60f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(20f, root_child0.LayoutHeight);

            Assert.AreEqual(30f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(20f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(20f, root_child2.LayoutHeight);

            Assert.AreEqual(60f, root_child3.LayoutX);
            Assert.AreEqual(40f, root_child3.LayoutY);
            Assert.AreEqual(20f, root_child3.LayoutWidth);
            Assert.AreEqual(20f, root_child3.LayoutHeight);

            Assert.AreEqual(30f, root_child4.LayoutX);
            Assert.AreEqual(40f, root_child4.LayoutY);
            Assert.AreEqual(20f, root_child4.LayoutWidth);
            Assert.AreEqual(20f, root_child4.LayoutHeight);

            Assert.AreEqual(0f, root_child5.LayoutX);
            Assert.AreEqual(40f, root_child5.LayoutY);
            Assert.AreEqual(20f, root_child5.LayoutWidth);
            Assert.AreEqual(20f, root_child5.LayoutHeight);

            Assert.AreEqual(60f, root_child6.LayoutX);
            Assert.AreEqual(80f, root_child6.LayoutY);
            Assert.AreEqual(20f, root_child6.LayoutWidth);
            Assert.AreEqual(20f, root_child6.LayoutHeight);

            Assert.AreEqual(30f, root_child7.LayoutX);
            Assert.AreEqual(80f, root_child7.LayoutY);
            Assert.AreEqual(20f, root_child7.LayoutWidth);
            Assert.AreEqual(20f, root_child7.LayoutHeight);

            Assert.AreEqual(0f, root_child8.LayoutX);
            Assert.AreEqual(80f, root_child8.LayoutY);
            Assert.AreEqual(20f, root_child8.LayoutWidth);
            Assert.AreEqual(20f, root_child8.LayoutHeight);
        }

        [Test]
        public void Test_column_gap_justify_flex_start()
        {
            YogaConfig config = new YogaConfig();
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.FixAbsoluteTrailingColumnMargin, true);

            YogaNode root = new YogaNode(config);
            root.FlexDirection = YogaFlexDirection.Row;
            root.Width = 100;
            root.Height = 100;
            root.ColumnGap = 10;

            YogaNode root_child0 = new YogaNode(config);
            root_child0.Width = 20;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);
            root_child1.Width = 20;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);
            root_child2.Width = 20;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(30f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(60f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(80f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(50f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(20f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);
        }

        [Test]
        public void Test_column_gap_justify_center()
        {
            YogaConfig config = new YogaConfig();
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.FixAbsoluteTrailingColumnMargin, true);

            YogaNode root = new YogaNode(config);
            root.FlexDirection = YogaFlexDirection.Row;
            root.JustifyContent = YogaJustify.Center;
            root.Width = 100;
            root.Height = 100;
            root.ColumnGap = 10;

            YogaNode root_child0 = new YogaNode(config);
            root_child0.Width = 20;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);
            root_child1.Width = 20;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);
            root_child2.Width = 20;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(10f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(40f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(70f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(70f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(40f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(10f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);
        }

        [Test]
        public void Test_column_gap_justify_flex_end()
        {
            YogaConfig config = new YogaConfig();
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.FixAbsoluteTrailingColumnMargin, true);

            YogaNode root = new YogaNode(config);
            root.FlexDirection = YogaFlexDirection.Row;
            root.JustifyContent = YogaJustify.FlexEnd;
            root.Width = 100;
            root.Height = 100;
            root.ColumnGap = 10;

            YogaNode root_child0 = new YogaNode(config);
            root_child0.Width = 20;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);
            root_child1.Width = 20;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);
            root_child2.Width = 20;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(20f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(50f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(80f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(60f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(30f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);
        }

        [Test]
        public void Test_column_gap_justify_space_between()
        {
            YogaConfig config = new YogaConfig();
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.FixAbsoluteTrailingColumnMargin, true);

            YogaNode root = new YogaNode(config);
            root.FlexDirection = YogaFlexDirection.Row;
            root.JustifyContent = YogaJustify.SpaceBetween;
            root.Width = 100;
            root.Height = 100;
            root.ColumnGap = 10;

            YogaNode root_child0 = new YogaNode(config);
            root_child0.Width = 20;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);
            root_child1.Width = 20;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);
            root_child2.Width = 20;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(40f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(80f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(80f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(40f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);
        }

        [Test]
        public void Test_column_gap_justify_space_around()
        {
            YogaConfig config = new YogaConfig();
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.FixAbsoluteTrailingColumnMargin, true);

            YogaNode root = new YogaNode(config);
            root.FlexDirection = YogaFlexDirection.Row;
            root.JustifyContent = YogaJustify.SpaceAround;
            root.Width = 100;
            root.Height = 100;
            root.ColumnGap = 10;

            YogaNode root_child0 = new YogaNode(config);
            root_child0.Width = 20;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);
            root_child1.Width = 20;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);
            root_child2.Width = 20;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(3f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(40f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(77f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(77f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(40f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(3f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);
        }

        [Test]
        public void Test_column_gap_justify_space_evenly()
        {
            YogaConfig config = new YogaConfig();
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.FixAbsoluteTrailingColumnMargin, true);

            YogaNode root = new YogaNode(config);
            root.FlexDirection = YogaFlexDirection.Row;
            root.JustifyContent = YogaJustify.SpaceEvenly;
            root.Width = 100;
            root.Height = 100;
            root.ColumnGap = 10;

            YogaNode root_child0 = new YogaNode(config);
            root_child0.Width = 20;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);
            root_child1.Width = 20;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);
            root_child2.Width = 20;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(5f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(40f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(75f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(75f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(40f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(5f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);
        }

        [Test]
        public void Test_column_gap_wrap_align_flex_start()
        {
            YogaConfig config = new YogaConfig();
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.FixAbsoluteTrailingColumnMargin, true);

            YogaNode root = new YogaNode(config);
            root.FlexDirection = YogaFlexDirection.Row;
            root.Wrap = YogaWrap.Wrap;
            root.Width = 100;
            root.Height = 100;
            root.ColumnGap = 10;
            root.RowGap = 20;

            YogaNode root_child0 = new YogaNode(config);
            root_child0.Width = 20;
            root_child0.Height = 20;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);
            root_child1.Width = 20;
            root_child1.Height = 20;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);
            root_child2.Width = 20;
            root_child2.Height = 20;
            root.Insert(2, root_child2);

            YogaNode root_child3 = new YogaNode(config);
            root_child3.Width = 20;
            root_child3.Height = 20;
            root.Insert(3, root_child3);

            YogaNode root_child4 = new YogaNode(config);
            root_child4.Width = 20;
            root_child4.Height = 20;
            root.Insert(4, root_child4);

            YogaNode root_child5 = new YogaNode(config);
            root_child5.Width = 20;
            root_child5.Height = 20;
            root.Insert(5, root_child5);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(20f, root_child0.LayoutHeight);

            Assert.AreEqual(30f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(20f, root_child1.LayoutHeight);

            Assert.AreEqual(60f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(20f, root_child2.LayoutHeight);

            Assert.AreEqual(0f, root_child3.LayoutX);
            Assert.AreEqual(40f, root_child3.LayoutY);
            Assert.AreEqual(20f, root_child3.LayoutWidth);
            Assert.AreEqual(20f, root_child3.LayoutHeight);

            Assert.AreEqual(30f, root_child4.LayoutX);
            Assert.AreEqual(40f, root_child4.LayoutY);
            Assert.AreEqual(20f, root_child4.LayoutWidth);
            Assert.AreEqual(20f, root_child4.LayoutHeight);

            Assert.AreEqual(60f, root_child5.LayoutX);
            Assert.AreEqual(40f, root_child5.LayoutY);
            Assert.AreEqual(20f, root_child5.LayoutWidth);
            Assert.AreEqual(20f, root_child5.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(80f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(20f, root_child0.LayoutHeight);

            Assert.AreEqual(50f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(20f, root_child1.LayoutHeight);

            Assert.AreEqual(20f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(20f, root_child2.LayoutHeight);

            Assert.AreEqual(80f, root_child3.LayoutX);
            Assert.AreEqual(40f, root_child3.LayoutY);
            Assert.AreEqual(20f, root_child3.LayoutWidth);
            Assert.AreEqual(20f, root_child3.LayoutHeight);

            Assert.AreEqual(50f, root_child4.LayoutX);
            Assert.AreEqual(40f, root_child4.LayoutY);
            Assert.AreEqual(20f, root_child4.LayoutWidth);
            Assert.AreEqual(20f, root_child4.LayoutHeight);

            Assert.AreEqual(20f, root_child5.LayoutX);
            Assert.AreEqual(40f, root_child5.LayoutY);
            Assert.AreEqual(20f, root_child5.LayoutWidth);
            Assert.AreEqual(20f, root_child5.LayoutHeight);
        }

        [Test]
        public void Test_column_gap_wrap_align_center()
        {
            YogaConfig config = new YogaConfig();
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.FixAbsoluteTrailingColumnMargin, true);

            YogaNode root = new YogaNode(config);
            root.FlexDirection = YogaFlexDirection.Row;
            root.AlignContent = YogaAlign.Center;
            root.Wrap = YogaWrap.Wrap;
            root.Width = 100;
            root.Height = 100;
            root.ColumnGap = 10;
            root.RowGap = 20;

            YogaNode root_child0 = new YogaNode(config);
            root_child0.Width = 20;
            root_child0.Height = 20;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);
            root_child1.Width = 20;
            root_child1.Height = 20;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);
            root_child2.Width = 20;
            root_child2.Height = 20;
            root.Insert(2, root_child2);

            YogaNode root_child3 = new YogaNode(config);
            root_child3.Width = 20;
            root_child3.Height = 20;
            root.Insert(3, root_child3);

            YogaNode root_child4 = new YogaNode(config);
            root_child4.Width = 20;
            root_child4.Height = 20;
            root.Insert(4, root_child4);

            YogaNode root_child5 = new YogaNode(config);
            root_child5.Width = 20;
            root_child5.Height = 20;
            root.Insert(5, root_child5);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(20f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(20f, root_child0.LayoutHeight);

            Assert.AreEqual(30f, root_child1.LayoutX);
            Assert.AreEqual(20f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(20f, root_child1.LayoutHeight);

            Assert.AreEqual(60f, root_child2.LayoutX);
            Assert.AreEqual(20f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(20f, root_child2.LayoutHeight);

            Assert.AreEqual(0f, root_child3.LayoutX);
            Assert.AreEqual(60f, root_child3.LayoutY);
            Assert.AreEqual(20f, root_child3.LayoutWidth);
            Assert.AreEqual(20f, root_child3.LayoutHeight);

            Assert.AreEqual(30f, root_child4.LayoutX);
            Assert.AreEqual(60f, root_child4.LayoutY);
            Assert.AreEqual(20f, root_child4.LayoutWidth);
            Assert.AreEqual(20f, root_child4.LayoutHeight);

            Assert.AreEqual(60f, root_child5.LayoutX);
            Assert.AreEqual(60f, root_child5.LayoutY);
            Assert.AreEqual(20f, root_child5.LayoutWidth);
            Assert.AreEqual(20f, root_child5.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(80f, root_child0.LayoutX);
            Assert.AreEqual(20f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(20f, root_child0.LayoutHeight);

            Assert.AreEqual(50f, root_child1.LayoutX);
            Assert.AreEqual(20f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(20f, root_child1.LayoutHeight);

            Assert.AreEqual(20f, root_child2.LayoutX);
            Assert.AreEqual(20f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(20f, root_child2.LayoutHeight);

            Assert.AreEqual(80f, root_child3.LayoutX);
            Assert.AreEqual(60f, root_child3.LayoutY);
            Assert.AreEqual(20f, root_child3.LayoutWidth);
            Assert.AreEqual(20f, root_child3.LayoutHeight);

            Assert.AreEqual(50f, root_child4.LayoutX);
            Assert.AreEqual(60f, root_child4.LayoutY);
            Assert.AreEqual(20f, root_child4.LayoutWidth);
            Assert.AreEqual(20f, root_child4.LayoutHeight);

            Assert.AreEqual(20f, root_child5.LayoutX);
            Assert.AreEqual(60f, root_child5.LayoutY);
            Assert.AreEqual(20f, root_child5.LayoutWidth);
            Assert.AreEqual(20f, root_child5.LayoutHeight);
        }

        [Test]
        public void Test_column_gap_wrap_align_flex_end()
        {
            YogaConfig config = new YogaConfig();
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.FixAbsoluteTrailingColumnMargin, true);

            YogaNode root = new YogaNode(config);
            root.FlexDirection = YogaFlexDirection.Row;
            root.AlignContent = YogaAlign.FlexEnd;
            root.Wrap = YogaWrap.Wrap;
            root.Width = 100;
            root.Height = 100;
            root.ColumnGap = 10;
            root.RowGap = 20;

            YogaNode root_child0 = new YogaNode(config);
            root_child0.Width = 20;
            root_child0.Height = 20;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);
            root_child1.Width = 20;
            root_child1.Height = 20;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);
            root_child2.Width = 20;
            root_child2.Height = 20;
            root.Insert(2, root_child2);

            YogaNode root_child3 = new YogaNode(config);
            root_child3.Width = 20;
            root_child3.Height = 20;
            root.Insert(3, root_child3);

            YogaNode root_child4 = new YogaNode(config);
            root_child4.Width = 20;
            root_child4.Height = 20;
            root.Insert(4, root_child4);

            YogaNode root_child5 = new YogaNode(config);
            root_child5.Width = 20;
            root_child5.Height = 20;
            root.Insert(5, root_child5);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(40f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(20f, root_child0.LayoutHeight);

            Assert.AreEqual(30f, root_child1.LayoutX);
            Assert.AreEqual(40f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(20f, root_child1.LayoutHeight);

            Assert.AreEqual(60f, root_child2.LayoutX);
            Assert.AreEqual(40f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(20f, root_child2.LayoutHeight);

            Assert.AreEqual(0f, root_child3.LayoutX);
            Assert.AreEqual(80f, root_child3.LayoutY);
            Assert.AreEqual(20f, root_child3.LayoutWidth);
            Assert.AreEqual(20f, root_child3.LayoutHeight);

            Assert.AreEqual(30f, root_child4.LayoutX);
            Assert.AreEqual(80f, root_child4.LayoutY);
            Assert.AreEqual(20f, root_child4.LayoutWidth);
            Assert.AreEqual(20f, root_child4.LayoutHeight);

            Assert.AreEqual(60f, root_child5.LayoutX);
            Assert.AreEqual(80f, root_child5.LayoutY);
            Assert.AreEqual(20f, root_child5.LayoutWidth);
            Assert.AreEqual(20f, root_child5.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(80f, root_child0.LayoutX);
            Assert.AreEqual(40f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(20f, root_child0.LayoutHeight);

            Assert.AreEqual(50f, root_child1.LayoutX);
            Assert.AreEqual(40f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(20f, root_child1.LayoutHeight);

            Assert.AreEqual(20f, root_child2.LayoutX);
            Assert.AreEqual(40f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(20f, root_child2.LayoutHeight);

            Assert.AreEqual(80f, root_child3.LayoutX);
            Assert.AreEqual(80f, root_child3.LayoutY);
            Assert.AreEqual(20f, root_child3.LayoutWidth);
            Assert.AreEqual(20f, root_child3.LayoutHeight);

            Assert.AreEqual(50f, root_child4.LayoutX);
            Assert.AreEqual(80f, root_child4.LayoutY);
            Assert.AreEqual(20f, root_child4.LayoutWidth);
            Assert.AreEqual(20f, root_child4.LayoutHeight);

            Assert.AreEqual(20f, root_child5.LayoutX);
            Assert.AreEqual(80f, root_child5.LayoutY);
            Assert.AreEqual(20f, root_child5.LayoutWidth);
            Assert.AreEqual(20f, root_child5.LayoutHeight);
        }

        [Test]
        public void Test_column_gap_wrap_align_space_between()
        {
            YogaConfig config = new YogaConfig();
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.FixAbsoluteTrailingColumnMargin, true);

            YogaNode root = new YogaNode(config);
            root.FlexDirection = YogaFlexDirection.Row;
            root.AlignContent = YogaAlign.SpaceBetween;
            root.Wrap = YogaWrap.Wrap;
            root.Width = 100;
            root.Height = 100;
            root.ColumnGap = 10;
            root.RowGap = 20;

            YogaNode root_child0 = new YogaNode(config);
            root_child0.Width = 20;
            root_child0.Height = 20;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);
            root_child1.Width = 20;
            root_child1.Height = 20;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);
            root_child2.Width = 20;
            root_child2.Height = 20;
            root.Insert(2, root_child2);

            YogaNode root_child3 = new YogaNode(config);
            root_child3.Width = 20;
            root_child3.Height = 20;
            root.Insert(3, root_child3);

            YogaNode root_child4 = new YogaNode(config);
            root_child4.Width = 20;
            root_child4.Height = 20;
            root.Insert(4, root_child4);

            YogaNode root_child5 = new YogaNode(config);
            root_child5.Width = 20;
            root_child5.Height = 20;
            root.Insert(5, root_child5);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(20f, root_child0.LayoutHeight);

            Assert.AreEqual(30f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(20f, root_child1.LayoutHeight);

            Assert.AreEqual(60f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(20f, root_child2.LayoutHeight);

            Assert.AreEqual(0f, root_child3.LayoutX);
            Assert.AreEqual(80f, root_child3.LayoutY);
            Assert.AreEqual(20f, root_child3.LayoutWidth);
            Assert.AreEqual(20f, root_child3.LayoutHeight);

            Assert.AreEqual(30f, root_child4.LayoutX);
            Assert.AreEqual(80f, root_child4.LayoutY);
            Assert.AreEqual(20f, root_child4.LayoutWidth);
            Assert.AreEqual(20f, root_child4.LayoutHeight);

            Assert.AreEqual(60f, root_child5.LayoutX);
            Assert.AreEqual(80f, root_child5.LayoutY);
            Assert.AreEqual(20f, root_child5.LayoutWidth);
            Assert.AreEqual(20f, root_child5.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(80f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(20f, root_child0.LayoutHeight);

            Assert.AreEqual(50f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(20f, root_child1.LayoutHeight);

            Assert.AreEqual(20f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(20f, root_child2.LayoutHeight);

            Assert.AreEqual(80f, root_child3.LayoutX);
            Assert.AreEqual(80f, root_child3.LayoutY);
            Assert.AreEqual(20f, root_child3.LayoutWidth);
            Assert.AreEqual(20f, root_child3.LayoutHeight);

            Assert.AreEqual(50f, root_child4.LayoutX);
            Assert.AreEqual(80f, root_child4.LayoutY);
            Assert.AreEqual(20f, root_child4.LayoutWidth);
            Assert.AreEqual(20f, root_child4.LayoutHeight);

            Assert.AreEqual(20f, root_child5.LayoutX);
            Assert.AreEqual(80f, root_child5.LayoutY);
            Assert.AreEqual(20f, root_child5.LayoutWidth);
            Assert.AreEqual(20f, root_child5.LayoutHeight);
        }

        [Test]
        public void Test_column_gap_wrap_align_space_around()
        {
            YogaConfig config = new YogaConfig();
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.FixAbsoluteTrailingColumnMargin, true);

            YogaNode root = new YogaNode(config);
            root.FlexDirection = YogaFlexDirection.Row;
            root.AlignContent = YogaAlign.SpaceAround;
            root.Wrap = YogaWrap.Wrap;
            root.Width = 100;
            root.Height = 100;
            root.ColumnGap = 10;
            root.RowGap = 20;

            YogaNode root_child0 = new YogaNode(config);
            root_child0.Width = 20;
            root_child0.Height = 20;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);
            root_child1.Width = 20;
            root_child1.Height = 20;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);
            root_child2.Width = 20;
            root_child2.Height = 20;
            root.Insert(2, root_child2);

            YogaNode root_child3 = new YogaNode(config);
            root_child3.Width = 20;
            root_child3.Height = 20;
            root.Insert(3, root_child3);

            YogaNode root_child4 = new YogaNode(config);
            root_child4.Width = 20;
            root_child4.Height = 20;
            root.Insert(4, root_child4);

            YogaNode root_child5 = new YogaNode(config);
            root_child5.Width = 20;
            root_child5.Height = 20;
            root.Insert(5, root_child5);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(10f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(20f, root_child0.LayoutHeight);

            Assert.AreEqual(30f, root_child1.LayoutX);
            Assert.AreEqual(10f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(20f, root_child1.LayoutHeight);

            Assert.AreEqual(60f, root_child2.LayoutX);
            Assert.AreEqual(10f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(20f, root_child2.LayoutHeight);

            Assert.AreEqual(0f, root_child3.LayoutX);
            Assert.AreEqual(70f, root_child3.LayoutY);
            Assert.AreEqual(20f, root_child3.LayoutWidth);
            Assert.AreEqual(20f, root_child3.LayoutHeight);

            Assert.AreEqual(30f, root_child4.LayoutX);
            Assert.AreEqual(70f, root_child4.LayoutY);
            Assert.AreEqual(20f, root_child4.LayoutWidth);
            Assert.AreEqual(20f, root_child4.LayoutHeight);

            Assert.AreEqual(60f, root_child5.LayoutX);
            Assert.AreEqual(70f, root_child5.LayoutY);
            Assert.AreEqual(20f, root_child5.LayoutWidth);
            Assert.AreEqual(20f, root_child5.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(80f, root_child0.LayoutX);
            Assert.AreEqual(10f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(20f, root_child0.LayoutHeight);

            Assert.AreEqual(50f, root_child1.LayoutX);
            Assert.AreEqual(10f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(20f, root_child1.LayoutHeight);

            Assert.AreEqual(20f, root_child2.LayoutX);
            Assert.AreEqual(10f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(20f, root_child2.LayoutHeight);

            Assert.AreEqual(80f, root_child3.LayoutX);
            Assert.AreEqual(70f, root_child3.LayoutY);
            Assert.AreEqual(20f, root_child3.LayoutWidth);
            Assert.AreEqual(20f, root_child3.LayoutHeight);

            Assert.AreEqual(50f, root_child4.LayoutX);
            Assert.AreEqual(70f, root_child4.LayoutY);
            Assert.AreEqual(20f, root_child4.LayoutWidth);
            Assert.AreEqual(20f, root_child4.LayoutHeight);

            Assert.AreEqual(20f, root_child5.LayoutX);
            Assert.AreEqual(70f, root_child5.LayoutY);
            Assert.AreEqual(20f, root_child5.LayoutWidth);
            Assert.AreEqual(20f, root_child5.LayoutHeight);
        }

        [Test]
        public void Test_column_gap_wrap_align_stretch()
        {
            YogaConfig config = new YogaConfig();
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.FixAbsoluteTrailingColumnMargin, true);

            YogaNode root = new YogaNode(config);
            root.FlexDirection = YogaFlexDirection.Row;
            root.AlignContent = YogaAlign.Stretch;
            root.Wrap = YogaWrap.Wrap;
            root.Width = 300;
            root.Height = 300;
            root.ColumnGap = 5;

            YogaNode root_child0 = new YogaNode(config);
            root_child0.FlexGrow = 1;
            root_child0.MinWidth = 60;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);
            root_child1.FlexGrow = 1;
            root_child1.MinWidth = 60;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);
            root_child2.FlexGrow = 1;
            root_child2.MinWidth = 60;
            root.Insert(2, root_child2);

            YogaNode root_child3 = new YogaNode(config);
            root_child3.FlexGrow = 1;
            root_child3.MinWidth = 60;
            root.Insert(3, root_child3);

            YogaNode root_child4 = new YogaNode(config);
            root_child4.FlexGrow = 1;
            root_child4.MinWidth = 60;
            root.Insert(4, root_child4);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(300f, root.LayoutWidth);
            Assert.AreEqual(300f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(71f, root_child0.LayoutWidth);
            Assert.AreEqual(150f, root_child0.LayoutHeight);

            Assert.AreEqual(76f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(72f, root_child1.LayoutWidth);
            Assert.AreEqual(150f, root_child1.LayoutHeight);

            Assert.AreEqual(153f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(71f, root_child2.LayoutWidth);
            Assert.AreEqual(150f, root_child2.LayoutHeight);

            Assert.AreEqual(229f, root_child3.LayoutX);
            Assert.AreEqual(0f, root_child3.LayoutY);
            Assert.AreEqual(71f, root_child3.LayoutWidth);
            Assert.AreEqual(150f, root_child3.LayoutHeight);

            Assert.AreEqual(0f, root_child4.LayoutX);
            Assert.AreEqual(150f, root_child4.LayoutY);
            Assert.AreEqual(300f, root_child4.LayoutWidth);
            Assert.AreEqual(150f, root_child4.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(300f, root.LayoutWidth);
            Assert.AreEqual(300f, root.LayoutHeight);

            Assert.AreEqual(229f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(71f, root_child0.LayoutWidth);
            Assert.AreEqual(150f, root_child0.LayoutHeight);

            Assert.AreEqual(153f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(71f, root_child1.LayoutWidth);
            Assert.AreEqual(150f, root_child1.LayoutHeight);

            Assert.AreEqual(76f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(72f, root_child2.LayoutWidth);
            Assert.AreEqual(150f, root_child2.LayoutHeight);

            Assert.AreEqual(0f, root_child3.LayoutX);
            Assert.AreEqual(0f, root_child3.LayoutY);
            Assert.AreEqual(71f, root_child3.LayoutWidth);
            Assert.AreEqual(150f, root_child3.LayoutHeight);

            Assert.AreEqual(0f, root_child4.LayoutX);
            Assert.AreEqual(150f, root_child4.LayoutY);
            Assert.AreEqual(300f, root_child4.LayoutWidth);
            Assert.AreEqual(150f, root_child4.LayoutHeight);
        }

        [Test]
        public void Test_column_gap_determines_parent_width()
        {
            YogaConfig config = new YogaConfig();
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.FixAbsoluteTrailingColumnMargin, true);

            YogaNode root = new YogaNode(config);
            root.FlexDirection = YogaFlexDirection.Row;
            root.Height = 100;
            root.ColumnGap = 10;

            YogaNode root_child0 = new YogaNode(config);
            root_child0.Width = 10;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);
            root_child1.Width = 20;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);
            root_child2.Width = 30;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(80f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(10f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(20f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(50f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(30f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(80f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(70f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(10f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(40f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(30f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);
        }

        [Test]
        public void Test_row_gap_align_items_stretch()
        {
            YogaConfig config = new YogaConfig();
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.FixAbsoluteTrailingColumnMargin, true);

            YogaNode root = new YogaNode(config);
            root.FlexDirection = YogaFlexDirection.Row;
            root.AlignContent = YogaAlign.Stretch;
            root.Wrap = YogaWrap.Wrap;
            root.Width = 100;
            root.Height = 200;
            root.ColumnGap = 10;
            root.RowGap = 20;

            YogaNode root_child0 = new YogaNode(config);
            root_child0.Width = 20;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);
            root_child1.Width = 20;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);
            root_child2.Width = 20;
            root.Insert(2, root_child2);

            YogaNode root_child3 = new YogaNode(config);
            root_child3.Width = 20;
            root.Insert(3, root_child3);

            YogaNode root_child4 = new YogaNode(config);
            root_child4.Width = 20;
            root.Insert(4, root_child4);

            YogaNode root_child5 = new YogaNode(config);
            root_child5.Width = 20;
            root.Insert(5, root_child5);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(200f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(90f, root_child0.LayoutHeight);

            Assert.AreEqual(30f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(90f, root_child1.LayoutHeight);

            Assert.AreEqual(60f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(90f, root_child2.LayoutHeight);

            Assert.AreEqual(0f, root_child3.LayoutX);
            Assert.AreEqual(110f, root_child3.LayoutY);
            Assert.AreEqual(20f, root_child3.LayoutWidth);
            Assert.AreEqual(90f, root_child3.LayoutHeight);

            Assert.AreEqual(30f, root_child4.LayoutX);
            Assert.AreEqual(110f, root_child4.LayoutY);
            Assert.AreEqual(20f, root_child4.LayoutWidth);
            Assert.AreEqual(90f, root_child4.LayoutHeight);

            Assert.AreEqual(60f, root_child5.LayoutX);
            Assert.AreEqual(110f, root_child5.LayoutY);
            Assert.AreEqual(20f, root_child5.LayoutWidth);
            Assert.AreEqual(90f, root_child5.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(200f, root.LayoutHeight);

            Assert.AreEqual(80f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(90f, root_child0.LayoutHeight);

            Assert.AreEqual(50f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(90f, root_child1.LayoutHeight);

            Assert.AreEqual(20f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(90f, root_child2.LayoutHeight);

            Assert.AreEqual(80f, root_child3.LayoutX);
            Assert.AreEqual(110f, root_child3.LayoutY);
            Assert.AreEqual(20f, root_child3.LayoutWidth);
            Assert.AreEqual(90f, root_child3.LayoutHeight);

            Assert.AreEqual(50f, root_child4.LayoutX);
            Assert.AreEqual(110f, root_child4.LayoutY);
            Assert.AreEqual(20f, root_child4.LayoutWidth);
            Assert.AreEqual(90f, root_child4.LayoutHeight);

            Assert.AreEqual(20f, root_child5.LayoutX);
            Assert.AreEqual(110f, root_child5.LayoutY);
            Assert.AreEqual(20f, root_child5.LayoutWidth);
            Assert.AreEqual(90f, root_child5.LayoutHeight);
        }

        [Test]
        public void Test_row_gap_align_items_end()
        {
            YogaConfig config = new YogaConfig();
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.FixAbsoluteTrailingColumnMargin, true);

            YogaNode root = new YogaNode(config);
            root.FlexDirection = YogaFlexDirection.Row;
            root.AlignItems = YogaAlign.FlexEnd;
            root.Wrap = YogaWrap.Wrap;
            root.Width = 100;
            root.Height = 200;
            root.ColumnGap = 10;
            root.RowGap = 20;

            YogaNode root_child0 = new YogaNode(config);
            root_child0.Width = 20;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);
            root_child1.Width = 20;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);
            root_child2.Width = 20;
            root.Insert(2, root_child2);

            YogaNode root_child3 = new YogaNode(config);
            root_child3.Width = 20;
            root.Insert(3, root_child3);

            YogaNode root_child4 = new YogaNode(config);
            root_child4.Width = 20;
            root.Insert(4, root_child4);

            YogaNode root_child5 = new YogaNode(config);
            root_child5.Width = 20;
            root.Insert(5, root_child5);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(200f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(0f, root_child0.LayoutHeight);

            Assert.AreEqual(30f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(0f, root_child1.LayoutHeight);

            Assert.AreEqual(60f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(0f, root_child2.LayoutHeight);

            Assert.AreEqual(0f, root_child3.LayoutX);
            Assert.AreEqual(20f, root_child3.LayoutY);
            Assert.AreEqual(20f, root_child3.LayoutWidth);
            Assert.AreEqual(0f, root_child3.LayoutHeight);

            Assert.AreEqual(30f, root_child4.LayoutX);
            Assert.AreEqual(20f, root_child4.LayoutY);
            Assert.AreEqual(20f, root_child4.LayoutWidth);
            Assert.AreEqual(0f, root_child4.LayoutHeight);

            Assert.AreEqual(60f, root_child5.LayoutX);
            Assert.AreEqual(20f, root_child5.LayoutY);
            Assert.AreEqual(20f, root_child5.LayoutWidth);
            Assert.AreEqual(0f, root_child5.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(200f, root.LayoutHeight);

            Assert.AreEqual(80f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(20f, root_child0.LayoutWidth);
            Assert.AreEqual(0f, root_child0.LayoutHeight);

            Assert.AreEqual(50f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(20f, root_child1.LayoutWidth);
            Assert.AreEqual(0f, root_child1.LayoutHeight);

            Assert.AreEqual(20f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(20f, root_child2.LayoutWidth);
            Assert.AreEqual(0f, root_child2.LayoutHeight);

            Assert.AreEqual(80f, root_child3.LayoutX);
            Assert.AreEqual(20f, root_child3.LayoutY);
            Assert.AreEqual(20f, root_child3.LayoutWidth);
            Assert.AreEqual(0f, root_child3.LayoutHeight);

            Assert.AreEqual(50f, root_child4.LayoutX);
            Assert.AreEqual(20f, root_child4.LayoutY);
            Assert.AreEqual(20f, root_child4.LayoutWidth);
            Assert.AreEqual(0f, root_child4.LayoutHeight);

            Assert.AreEqual(20f, root_child5.LayoutX);
            Assert.AreEqual(20f, root_child5.LayoutY);
            Assert.AreEqual(20f, root_child5.LayoutWidth);
            Assert.AreEqual(0f, root_child5.LayoutHeight);
        }

        [Test]
        public void Test_row_gap_column_child_margins()
        {
            YogaConfig config = new YogaConfig();
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.FixAbsoluteTrailingColumnMargin, true);

            YogaNode root = new YogaNode(config);
            root.Width = 100;
            root.Height = 200;
            root.RowGap = 10;

            YogaNode root_child0 = new YogaNode(config);
            root_child0.FlexGrow = 1;
            root_child0.FlexShrink = 1;
            root_child0.FlexBasis = 0.Percent();
            root_child0.MarginTop = 2;
            root_child0.MarginBottom = 2;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);
            root_child1.FlexGrow = 1;
            root_child1.FlexShrink = 1;
            root_child1.FlexBasis = 0.Percent();
            root_child1.MarginTop = 10;
            root_child1.MarginBottom = 10;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);
            root_child2.FlexGrow = 1;
            root_child2.FlexShrink = 1;
            root_child2.FlexBasis = 0.Percent();
            root_child2.MarginTop = 15;
            root_child2.MarginBottom = 15;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(200f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(2f, root_child0.LayoutY);
            Assert.AreEqual(100f, root_child0.LayoutWidth);
            Assert.AreEqual(42f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(66f, root_child1.LayoutY);
            Assert.AreEqual(100f, root_child1.LayoutWidth);
            Assert.AreEqual(42f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(143f, root_child2.LayoutY);
            Assert.AreEqual(100f, root_child2.LayoutWidth);
            Assert.AreEqual(42f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(200f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(2f, root_child0.LayoutY);
            Assert.AreEqual(100f, root_child0.LayoutWidth);
            Assert.AreEqual(42f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(66f, root_child1.LayoutY);
            Assert.AreEqual(100f, root_child1.LayoutWidth);
            Assert.AreEqual(42f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(143f, root_child2.LayoutY);
            Assert.AreEqual(100f, root_child2.LayoutWidth);
            Assert.AreEqual(42f, root_child2.LayoutHeight);
        }

        [Test]
        public void Test_row_gap_row_wrap_child_margins()
        {
            YogaConfig config = new YogaConfig();
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.FixAbsoluteTrailingColumnMargin, true);

            YogaNode root = new YogaNode(config);
            root.FlexDirection = YogaFlexDirection.Row;
            root.Wrap = YogaWrap.Wrap;
            root.Width = 100;
            root.Height = 200;
            root.RowGap = 10;

            YogaNode root_child0 = new YogaNode(config);
            root_child0.MarginTop = 2;
            root_child0.MarginBottom = 2;
            root_child0.Width = 60;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);
            root_child1.MarginTop = 10;
            root_child1.MarginBottom = 10;
            root_child1.Width = 60;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);
            root_child2.MarginTop = 15;
            root_child2.MarginBottom = 15;
            root_child2.Width = 60;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(200f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(2f, root_child0.LayoutY);
            Assert.AreEqual(60f, root_child0.LayoutWidth);
            Assert.AreEqual(0f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(24f, root_child1.LayoutY);
            Assert.AreEqual(60f, root_child1.LayoutWidth);
            Assert.AreEqual(0f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(59f, root_child2.LayoutY);
            Assert.AreEqual(60f, root_child2.LayoutWidth);
            Assert.AreEqual(0f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(200f, root.LayoutHeight);

            Assert.AreEqual(40f, root_child0.LayoutX);
            Assert.AreEqual(2f, root_child0.LayoutY);
            Assert.AreEqual(60f, root_child0.LayoutWidth);
            Assert.AreEqual(0f, root_child0.LayoutHeight);

            Assert.AreEqual(40f, root_child1.LayoutX);
            Assert.AreEqual(24f, root_child1.LayoutY);
            Assert.AreEqual(60f, root_child1.LayoutWidth);
            Assert.AreEqual(0f, root_child1.LayoutHeight);

            Assert.AreEqual(40f, root_child2.LayoutX);
            Assert.AreEqual(59f, root_child2.LayoutY);
            Assert.AreEqual(60f, root_child2.LayoutWidth);
            Assert.AreEqual(0f, root_child2.LayoutHeight);
        }

        [Test]
        public void Test_row_gap_determines_parent_height()
        {
            YogaConfig config = new YogaConfig();
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
            config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.FixAbsoluteTrailingColumnMargin, true);

            YogaNode root = new YogaNode(config);
            root.Width = 100;
            root.RowGap = 10;

            YogaNode root_child0 = new YogaNode(config);
            root_child0.Height = 10;
            root.Insert(0, root_child0);

            YogaNode root_child1 = new YogaNode(config);
            root_child1.Height = 20;
            root.Insert(1, root_child1);

            YogaNode root_child2 = new YogaNode(config);
            root_child2.Height = 30;
            root.Insert(2, root_child2);
            root.StyleDirection = YogaDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(80f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(100f, root_child0.LayoutWidth);
            Assert.AreEqual(10f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(20f, root_child1.LayoutY);
            Assert.AreEqual(100f, root_child1.LayoutWidth);
            Assert.AreEqual(20f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(50f, root_child2.LayoutY);
            Assert.AreEqual(100f, root_child2.LayoutWidth);
            Assert.AreEqual(30f, root_child2.LayoutHeight);

            root.StyleDirection = YogaDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(80f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(100f, root_child0.LayoutWidth);
            Assert.AreEqual(10f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(20f, root_child1.LayoutY);
            Assert.AreEqual(100f, root_child1.LayoutWidth);
            Assert.AreEqual(20f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(50f, root_child2.LayoutY);
            Assert.AreEqual(100f, root_child2.LayoutWidth);
            Assert.AreEqual(30f, root_child2.LayoutHeight);
        }

    }
}
