Move configuration to new YGConfig and pass them down to CalculateLayout

Summary:
Move configuration to new ```YGConfig``` and pass them down to CalculateLayout. See #418 .

Adds ```YGConfigNew()``` + ```YGConfigFree```, and changed ```YGSetExperimentalFeatureEnabled``` to use the config.

New function for calculation is ```YGNodeCalculateLayoutWithConfig```.
Closes https://github.com/facebook/yoga/pull/432

Reviewed By: astreet

Differential Revision: D4611359

Pulled By: emilsjolander

fbshipit-source-id: a1332f0e1b21cec02129dd021ee57408449e10b0
This commit is contained in:
Lukas Wöhrl
2017-03-01 09:19:55 -08:00
committed by Facebook Github Bot
parent 8668e43f6d
commit 37c48257ae
89 changed files with 4536 additions and 3049 deletions

View File

@@ -13,11 +13,13 @@
#include <yoga/Yoga.h>
TEST(YogaTest, absolute_layout_width_height_start_top) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetPosition(root_child0, YGEdgeStart, 10);
YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10);
@@ -49,14 +51,18 @@ TEST(YogaTest, absolute_layout_width_height_start_top) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, absolute_layout_width_height_end_bottom) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetPosition(root_child0, YGEdgeEnd, 10);
YGNodeStyleSetPosition(root_child0, YGEdgeBottom, 10);
@@ -88,14 +94,18 @@ TEST(YogaTest, absolute_layout_width_height_end_bottom) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, absolute_layout_start_top_end_bottom) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetPosition(root_child0, YGEdgeStart, 10);
YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10);
@@ -127,14 +137,18 @@ TEST(YogaTest, absolute_layout_start_top_end_bottom) {
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, absolute_layout_width_height_start_top_end_bottom) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetPosition(root_child0, YGEdgeStart, 10);
YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10);
@@ -168,22 +182,26 @@ TEST(YogaTest, absolute_layout_width_height_start_top_end_bottom) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetOverflow(root, YGOverflowHidden);
YGNodeStyleSetWidth(root, 50);
YGNodeStyleSetHeight(root, 50);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetPosition(root_child0, YGEdgeStart, 0);
YGNodeStyleSetPosition(root_child0, YGEdgeTop, 0);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0_child0, 100);
YGNodeStyleSetHeight(root_child0_child0, 100);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
@@ -222,10 +240,14 @@ TEST(YogaTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hi
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, absolute_layout_within_border) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetMargin(root, YGEdgeLeft, 10);
YGNodeStyleSetMargin(root, YGEdgeTop, 10);
YGNodeStyleSetMargin(root, YGEdgeRight, 10);
@@ -241,7 +263,7 @@ TEST(YogaTest, absolute_layout_within_border) {
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 0);
YGNodeStyleSetPosition(root_child0, YGEdgeTop, 0);
@@ -249,7 +271,7 @@ TEST(YogaTest, absolute_layout_within_border) {
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child1, YGPositionTypeAbsolute);
YGNodeStyleSetPosition(root_child1, YGEdgeRight, 0);
YGNodeStyleSetPosition(root_child1, YGEdgeBottom, 0);
@@ -291,17 +313,21 @@ TEST(YogaTest, absolute_layout_within_border) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, absolute_layout_align_items_and_justify_content_center) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetFlexGrow(root, 1);
YGNodeStyleSetWidth(root, 110);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetWidth(root_child0, 60);
YGNodeStyleSetHeight(root_child0, 40);
@@ -331,17 +357,21 @@ TEST(YogaTest, absolute_layout_align_items_and_justify_content_center) {
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, absolute_layout_align_items_and_justify_content_flex_end) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd);
YGNodeStyleSetAlignItems(root, YGAlignFlexEnd);
YGNodeStyleSetFlexGrow(root, 1);
YGNodeStyleSetWidth(root, 110);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetWidth(root_child0, 60);
YGNodeStyleSetHeight(root_child0, 40);
@@ -371,16 +401,20 @@ TEST(YogaTest, absolute_layout_align_items_and_justify_content_flex_end) {
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, absolute_layout_justify_content_center) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
YGNodeStyleSetFlexGrow(root, 1);
YGNodeStyleSetWidth(root, 110);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetWidth(root_child0, 60);
YGNodeStyleSetHeight(root_child0, 40);
@@ -410,16 +444,20 @@ TEST(YogaTest, absolute_layout_justify_content_center) {
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, absolute_layout_align_items_center) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetFlexGrow(root, 1);
YGNodeStyleSetWidth(root, 110);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetWidth(root_child0, 60);
YGNodeStyleSetHeight(root_child0, 40);
@@ -449,15 +487,19 @@ TEST(YogaTest, absolute_layout_align_items_center) {
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, absolute_layout_align_items_center_on_child_only) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root, 1);
YGNodeStyleSetWidth(root, 110);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignSelf(root_child0, YGAlignCenter);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetWidth(root_child0, 60);
@@ -488,17 +530,21 @@ TEST(YogaTest, absolute_layout_align_items_center_on_child_only) {
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_top_position) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetFlexGrow(root, 1);
YGNodeStyleSetWidth(root, 110);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10);
YGNodeStyleSetWidth(root_child0, 60);
@@ -529,17 +575,21 @@ TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_top_po
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_bottom_position) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetFlexGrow(root, 1);
YGNodeStyleSetWidth(root, 110);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetPosition(root_child0, YGEdgeBottom, 10);
YGNodeStyleSetWidth(root_child0, 60);
@@ -570,17 +620,21 @@ TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_bottom
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_left_position) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetFlexGrow(root, 1);
YGNodeStyleSetWidth(root, 110);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 5);
YGNodeStyleSetWidth(root_child0, 60);
@@ -611,17 +665,21 @@ TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_left_p
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_right_position) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetFlexGrow(root, 1);
YGNodeStyleSetWidth(root, 110);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetPosition(root_child0, YGEdgeRight, 5);
YGNodeStyleSetWidth(root_child0, 60);
@@ -652,4 +710,6 @@ TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_right_
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}

View File

@@ -13,33 +13,35 @@
#include <yoga/Yoga.h>
TEST(YogaTest, align_content_flex_start) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 130);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeStyleSetHeight(root_child3, 10);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeStyleSetHeight(root_child4, 10);
YGNodeInsertChild(root, root_child4, 4);
@@ -108,33 +110,37 @@ TEST(YogaTest, align_content_flex_start) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_flex_start_without_height_on_children) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeStyleSetHeight(root_child3, 10);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -202,39 +208,43 @@ TEST(YogaTest, align_content_flex_start_without_height_on_children) {
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_flex_start_with_flex) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 120);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 0);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetFlexBasisPercent(root_child1, 0);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child3, 1);
YGNodeStyleSetFlexShrink(root_child3, 1);
YGNodeStyleSetFlexBasisPercent(root_child3, 0);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -302,36 +312,40 @@ TEST(YogaTest, align_content_flex_start_with_flex) {
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_flex_end) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignContent(root, YGAlignFlexEnd);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeStyleSetHeight(root_child3, 10);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeStyleSetHeight(root_child4, 10);
YGNodeInsertChild(root, root_child4, 4);
@@ -400,32 +414,36 @@ TEST(YogaTest, align_content_flex_end) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_stretch) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 150);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -493,37 +511,41 @@ TEST(YogaTest, align_content_stretch) {
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_spacebetween) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignSpaceBetween);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 130);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeStyleSetHeight(root_child3, 10);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeStyleSetHeight(root_child4, 10);
YGNodeInsertChild(root, root_child4, 4);
@@ -592,37 +614,41 @@ TEST(YogaTest, align_content_spacebetween) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_spacearound) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignSpaceAround);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 140);
YGNodeStyleSetHeight(root, 120);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeStyleSetHeight(root_child3, 10);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeStyleSetHeight(root_child4, 10);
YGNodeInsertChild(root, root_child4, 4);
@@ -691,33 +717,37 @@ TEST(YogaTest, align_content_spacearound) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_stretch_row) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 150);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -785,39 +815,43 @@ TEST(YogaTest, align_content_stretch_row) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_stretch_row_with_children) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 150);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0_child0, 1);
YGNodeStyleSetFlexShrink(root_child0_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0_child0, 0);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -895,39 +929,43 @@ TEST(YogaTest, align_content_stretch_row_with_children) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_stretch_row_with_flex) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 150);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetFlexShrink(root_child1, 1);
YGNodeStyleSetFlexBasisPercent(root_child1, 0);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child3, 1);
YGNodeStyleSetFlexShrink(root_child3, 1);
YGNodeStyleSetFlexBasisPercent(root_child3, 0);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -995,38 +1033,42 @@ TEST(YogaTest, align_content_stretch_row_with_flex) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_stretch_row_with_flex_no_shrink) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 150);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetFlexShrink(root_child1, 1);
YGNodeStyleSetFlexBasisPercent(root_child1, 0);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child3, 1);
YGNodeStyleSetFlexBasisPercent(root_child3, 0);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -1094,21 +1136,25 @@ TEST(YogaTest, align_content_stretch_row_with_flex_no_shrink) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_stretch_row_with_margin) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 150);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetMargin(root_child1, YGEdgeLeft, 10);
YGNodeStyleSetMargin(root_child1, YGEdgeTop, 10);
YGNodeStyleSetMargin(root_child1, YGEdgeRight, 10);
@@ -1116,11 +1162,11 @@ TEST(YogaTest, align_content_stretch_row_with_margin) {
YGNodeStyleSetWidth(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetMargin(root_child3, YGEdgeLeft, 10);
YGNodeStyleSetMargin(root_child3, YGEdgeTop, 10);
YGNodeStyleSetMargin(root_child3, YGEdgeRight, 10);
@@ -1128,7 +1174,7 @@ TEST(YogaTest, align_content_stretch_row_with_margin) {
YGNodeStyleSetWidth(root_child3, 50);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -1196,21 +1242,25 @@ TEST(YogaTest, align_content_stretch_row_with_margin) {
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_stretch_row_with_padding) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 150);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetPadding(root_child1, YGEdgeLeft, 10);
YGNodeStyleSetPadding(root_child1, YGEdgeTop, 10);
YGNodeStyleSetPadding(root_child1, YGEdgeRight, 10);
@@ -1218,11 +1268,11 @@ TEST(YogaTest, align_content_stretch_row_with_padding) {
YGNodeStyleSetWidth(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetPadding(root_child3, YGEdgeLeft, 10);
YGNodeStyleSetPadding(root_child3, YGEdgeTop, 10);
YGNodeStyleSetPadding(root_child3, YGEdgeRight, 10);
@@ -1230,7 +1280,7 @@ TEST(YogaTest, align_content_stretch_row_with_padding) {
YGNodeStyleSetWidth(root_child3, 50);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -1298,21 +1348,25 @@ TEST(YogaTest, align_content_stretch_row_with_padding) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_stretch_row_with_single_row) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 150);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -1350,34 +1404,38 @@ TEST(YogaTest, align_content_stretch_row_with_single_row) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_stretch_row_with_fixed_height) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 150);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 60);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -1445,34 +1503,38 @@ TEST(YogaTest, align_content_stretch_row_with_fixed_height) {
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_stretch_row_with_max_height) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 150);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetMaxHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -1540,34 +1602,38 @@ TEST(YogaTest, align_content_stretch_row_with_max_height) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_stretch_row_with_min_height) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 150);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetMinHeight(root_child1, 80);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -1635,41 +1701,45 @@ TEST(YogaTest, align_content_stretch_row_with_min_height) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_stretch_column) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 150);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0_child0, 1);
YGNodeStyleSetFlexShrink(root_child0_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0_child0, 0);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetFlexShrink(root_child1, 1);
YGNodeStyleSetFlexBasisPercent(root_child1, 0);
YGNodeStyleSetHeight(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child3, 50);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -1747,13 +1817,17 @@ TEST(YogaTest, align_content_stretch_column) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_content_stretch_is_not_overriding_align_items) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root_child0, YGAlignStretch);
YGNodeStyleSetAlignItems(root_child0, YGAlignCenter);
@@ -1761,7 +1835,7 @@ TEST(YogaTest, align_content_stretch_is_not_overriding_align_items) {
YGNodeStyleSetHeight(root_child0, 100);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignContent(root_child0_child0, YGAlignStretch);
YGNodeStyleSetWidth(root_child0_child0, 10);
YGNodeStyleSetHeight(root_child0_child0, 10);
@@ -1801,4 +1875,6 @@ TEST(YogaTest, align_content_stretch_is_not_overriding_align_items) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}

View File

@@ -13,11 +13,13 @@
#include <yoga/Yoga.h>
TEST(YogaTest, align_items_stretch) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -45,15 +47,19 @@ TEST(YogaTest, align_items_stretch) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_items_center) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
@@ -82,15 +88,19 @@ TEST(YogaTest, align_items_center) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_items_flex_start) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
@@ -119,15 +129,19 @@ TEST(YogaTest, align_items_flex_start) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_items_flex_end) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignItems(root, YGAlignFlexEnd);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
@@ -156,21 +170,25 @@ TEST(YogaTest, align_items_flex_end) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_baseline) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignItems(root, YGAlignBaseline);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
@@ -209,26 +227,30 @@ TEST(YogaTest, align_baseline) {
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_baseline_child) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignItems(root, YGAlignBaseline);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1_child0 = YGNodeNew();
const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1_child0, 50);
YGNodeStyleSetHeight(root_child1_child0, 10);
YGNodeInsertChild(root_child1, root_child1_child0, 0);
@@ -277,43 +299,47 @@ TEST(YogaTest, align_baseline_child) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_baseline_child_multiline) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignItems(root, YGAlignBaseline);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root_child1, YGFlexDirectionRow);
YGNodeStyleSetFlexWrap(root_child1, YGWrapWrap);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 25);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1_child0 = YGNodeNew();
const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1_child0, 25);
YGNodeStyleSetHeight(root_child1_child0, 20);
YGNodeInsertChild(root_child1, root_child1_child0, 0);
const YGNodeRef root_child1_child1 = YGNodeNew();
const YGNodeRef root_child1_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1_child1, 25);
YGNodeStyleSetHeight(root_child1_child1, 10);
YGNodeInsertChild(root_child1, root_child1_child1, 1);
const YGNodeRef root_child1_child2 = YGNodeNew();
const YGNodeRef root_child1_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1_child2, 25);
YGNodeStyleSetHeight(root_child1_child2, 20);
YGNodeInsertChild(root_child1, root_child1_child2, 2);
const YGNodeRef root_child1_child3 = YGNodeNew();
const YGNodeRef root_child1_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1_child3, 25);
YGNodeStyleSetHeight(root_child1_child3, 10);
YGNodeInsertChild(root_child1, root_child1_child3, 3);
@@ -392,44 +418,48 @@ TEST(YogaTest, align_baseline_child_multiline) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child3));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_baseline_child_multiline_override) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignItems(root, YGAlignBaseline);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root_child1, YGFlexDirectionRow);
YGNodeStyleSetFlexWrap(root_child1, YGWrapWrap);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 25);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1_child0 = YGNodeNew();
const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1_child0, 25);
YGNodeStyleSetHeight(root_child1_child0, 20);
YGNodeInsertChild(root_child1, root_child1_child0, 0);
const YGNodeRef root_child1_child1 = YGNodeNew();
const YGNodeRef root_child1_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignSelf(root_child1_child1, YGAlignBaseline);
YGNodeStyleSetWidth(root_child1_child1, 25);
YGNodeStyleSetHeight(root_child1_child1, 10);
YGNodeInsertChild(root_child1, root_child1_child1, 1);
const YGNodeRef root_child1_child2 = YGNodeNew();
const YGNodeRef root_child1_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1_child2, 25);
YGNodeStyleSetHeight(root_child1_child2, 20);
YGNodeInsertChild(root_child1, root_child1_child2, 2);
const YGNodeRef root_child1_child3 = YGNodeNew();
const YGNodeRef root_child1_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignSelf(root_child1_child3, YGAlignBaseline);
YGNodeStyleSetWidth(root_child1_child3, 25);
YGNodeStyleSetHeight(root_child1_child3, 10);
@@ -509,43 +539,47 @@ TEST(YogaTest, align_baseline_child_multiline_override) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child3));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_baseline_child_multiline_no_override_on_secondline) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignItems(root, YGAlignBaseline);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root_child1, YGFlexDirectionRow);
YGNodeStyleSetFlexWrap(root_child1, YGWrapWrap);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 25);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1_child0 = YGNodeNew();
const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1_child0, 25);
YGNodeStyleSetHeight(root_child1_child0, 20);
YGNodeInsertChild(root_child1, root_child1_child0, 0);
const YGNodeRef root_child1_child1 = YGNodeNew();
const YGNodeRef root_child1_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1_child1, 25);
YGNodeStyleSetHeight(root_child1_child1, 10);
YGNodeInsertChild(root_child1, root_child1_child1, 1);
const YGNodeRef root_child1_child2 = YGNodeNew();
const YGNodeRef root_child1_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1_child2, 25);
YGNodeStyleSetHeight(root_child1_child2, 20);
YGNodeInsertChild(root_child1, root_child1_child2, 2);
const YGNodeRef root_child1_child3 = YGNodeNew();
const YGNodeRef root_child1_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignSelf(root_child1_child3, YGAlignBaseline);
YGNodeStyleSetWidth(root_child1_child3, 25);
YGNodeStyleSetHeight(root_child1_child3, 10);
@@ -625,27 +659,31 @@ TEST(YogaTest, align_baseline_child_multiline_no_override_on_secondline) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child3));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_baseline_child_top) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignItems(root, YGAlignBaseline);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1_child0 = YGNodeNew();
const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1_child0, 50);
YGNodeStyleSetHeight(root_child1_child0, 10);
YGNodeInsertChild(root_child1, root_child1_child0, 0);
@@ -694,27 +732,31 @@ TEST(YogaTest, align_baseline_child_top) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_baseline_child_top2) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignItems(root, YGAlignBaseline);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetPosition(root_child1, YGEdgeTop, 5);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1_child0 = YGNodeNew();
const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1_child0, 50);
YGNodeStyleSetHeight(root_child1_child0, 10);
YGNodeInsertChild(root_child1, root_child1_child0, 0);
@@ -763,31 +805,35 @@ TEST(YogaTest, align_baseline_child_top2) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_baseline_double_nested_child) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignItems(root, YGAlignBaseline);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0_child0, 50);
YGNodeStyleSetHeight(root_child0_child0, 20);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1_child0 = YGNodeNew();
const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1_child0, 50);
YGNodeStyleSetHeight(root_child1_child0, 15);
YGNodeInsertChild(root_child1, root_child1_child0, 0);
@@ -846,20 +892,24 @@ TEST(YogaTest, align_baseline_double_nested_child) {
ASSERT_FLOAT_EQ(15, YGNodeLayoutGetHeight(root_child1_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_baseline_column) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignItems(root, YGAlignBaseline);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
@@ -898,16 +948,20 @@ TEST(YogaTest, align_baseline_column) {
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_baseline_child_margin) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignItems(root, YGAlignBaseline);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 5);
YGNodeStyleSetMargin(root_child0, YGEdgeTop, 5);
YGNodeStyleSetMargin(root_child0, YGEdgeRight, 5);
@@ -916,12 +970,12 @@ TEST(YogaTest, align_baseline_child_margin) {
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1_child0 = YGNodeNew();
const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetMargin(root_child1_child0, YGEdgeLeft, 1);
YGNodeStyleSetMargin(root_child1_child0, YGEdgeTop, 1);
YGNodeStyleSetMargin(root_child1_child0, YGEdgeRight, 1);
@@ -974,10 +1028,14 @@ TEST(YogaTest, align_baseline_child_margin) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_baseline_child_padding) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignItems(root, YGAlignBaseline);
YGNodeStyleSetPadding(root, YGEdgeLeft, 5);
@@ -987,12 +1045,12 @@ TEST(YogaTest, align_baseline_child_padding) {
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetPadding(root_child1, YGEdgeLeft, 5);
YGNodeStyleSetPadding(root_child1, YGEdgeTop, 5);
YGNodeStyleSetPadding(root_child1, YGEdgeRight, 5);
@@ -1001,7 +1059,7 @@ TEST(YogaTest, align_baseline_child_padding) {
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1_child0 = YGNodeNew();
const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1_child0, 50);
YGNodeStyleSetHeight(root_child1_child0, 10);
YGNodeInsertChild(root_child1, root_child1_child0, 0);
@@ -1050,42 +1108,46 @@ TEST(YogaTest, align_baseline_child_padding) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_baseline_multiline) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignItems(root, YGAlignBaseline);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1_child0 = YGNodeNew();
const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1_child0, 50);
YGNodeStyleSetHeight(root_child1_child0, 10);
YGNodeInsertChild(root_child1, root_child1_child0, 0);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeStyleSetHeight(root_child2, 20);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child2_child0 = YGNodeNew();
const YGNodeRef root_child2_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2_child0, 50);
YGNodeStyleSetHeight(root_child2_child0, 10);
YGNodeInsertChild(root_child2, root_child2_child0, 0);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeStyleSetHeight(root_child3, 50);
YGNodeInsertChild(root, root_child3, 3);
@@ -1164,41 +1226,45 @@ TEST(YogaTest, align_baseline_multiline) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child3));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_baseline_multiline_column) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignItems(root, YGAlignBaseline);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 30);
YGNodeStyleSetHeight(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1_child0 = YGNodeNew();
const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1_child0, 20);
YGNodeStyleSetHeight(root_child1_child0, 20);
YGNodeInsertChild(root_child1, root_child1_child0, 0);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 40);
YGNodeStyleSetHeight(root_child2, 70);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child2_child0 = YGNodeNew();
const YGNodeRef root_child2_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2_child0, 10);
YGNodeStyleSetHeight(root_child2_child0, 10);
YGNodeInsertChild(root_child2, root_child2_child0, 0);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeStyleSetHeight(root_child3, 20);
YGNodeInsertChild(root, root_child3, 3);
@@ -1277,41 +1343,45 @@ TEST(YogaTest, align_baseline_multiline_column) {
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child3));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_baseline_multiline_column2) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignItems(root, YGAlignBaseline);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 30);
YGNodeStyleSetHeight(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1_child0 = YGNodeNew();
const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1_child0, 20);
YGNodeStyleSetHeight(root_child1_child0, 20);
YGNodeInsertChild(root_child1, root_child1_child0, 0);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 40);
YGNodeStyleSetHeight(root_child2, 70);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child2_child0 = YGNodeNew();
const YGNodeRef root_child2_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2_child0, 10);
YGNodeStyleSetHeight(root_child2_child0, 10);
YGNodeInsertChild(root_child2, root_child2_child0, 0);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeStyleSetHeight(root_child3, 20);
YGNodeInsertChild(root, root_child3, 3);
@@ -1390,42 +1460,46 @@ TEST(YogaTest, align_baseline_multiline_column2) {
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child3));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_baseline_multiline_row_and_column) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignItems(root, YGAlignBaseline);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1_child0 = YGNodeNew();
const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1_child0, 50);
YGNodeStyleSetHeight(root_child1_child0, 10);
YGNodeInsertChild(root_child1, root_child1_child0, 0);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeStyleSetHeight(root_child2, 20);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child2_child0 = YGNodeNew();
const YGNodeRef root_child2_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2_child0, 50);
YGNodeStyleSetHeight(root_child2_child0, 10);
YGNodeInsertChild(root_child2, root_child2_child0, 0);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 50);
YGNodeStyleSetHeight(root_child3, 20);
YGNodeInsertChild(root, root_child3, 3);
@@ -1504,4 +1578,6 @@ TEST(YogaTest, align_baseline_multiline_row_and_column) {
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child3));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}

View File

@@ -13,11 +13,13 @@
#include <yoga/Yoga.h>
TEST(YogaTest, align_self_center) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignSelf(root_child0, YGAlignCenter);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
@@ -47,14 +49,18 @@ TEST(YogaTest, align_self_center) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_self_flex_end) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignSelf(root_child0, YGAlignFlexEnd);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
@@ -84,14 +90,18 @@ TEST(YogaTest, align_self_flex_end) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_self_flex_start) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignSelf(root_child0, YGAlignFlexStart);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
@@ -121,15 +131,19 @@ TEST(YogaTest, align_self_flex_start) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_self_flex_end_override_flex_start) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignSelf(root_child0, YGAlignFlexEnd);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
@@ -159,27 +173,31 @@ TEST(YogaTest, align_self_flex_end_override_flex_start) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_self_baseline) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignSelf(root_child0, YGAlignBaseline);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignSelf(root_child1, YGAlignBaseline);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1_child0 = YGNodeNew();
const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1_child0, 50);
YGNodeStyleSetHeight(root_child1_child0, 10);
YGNodeInsertChild(root_child1, root_child1_child0, 0);
@@ -228,4 +246,6 @@ TEST(YogaTest, align_self_baseline) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}

View File

@@ -13,7 +13,9 @@
#include <yoga/Yoga.h>
TEST(YogaTest, border_no_size) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetBorder(root, YGEdgeLeft, 10);
YGNodeStyleSetBorder(root, YGEdgeTop, 10);
YGNodeStyleSetBorder(root, YGEdgeRight, 10);
@@ -33,16 +35,20 @@ TEST(YogaTest, border_no_size) {
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, border_container_match_child) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetBorder(root, YGEdgeLeft, 10);
YGNodeStyleSetBorder(root, YGEdgeTop, 10);
YGNodeStyleSetBorder(root, YGEdgeRight, 10);
YGNodeStyleSetBorder(root, YGEdgeBottom, 10);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
@@ -71,10 +77,14 @@ TEST(YogaTest, border_container_match_child) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, border_flex_child) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetBorder(root, YGEdgeLeft, 10);
YGNodeStyleSetBorder(root, YGEdgeTop, 10);
YGNodeStyleSetBorder(root, YGEdgeRight, 10);
@@ -82,7 +92,7 @@ TEST(YogaTest, border_flex_child) {
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
@@ -111,10 +121,14 @@ TEST(YogaTest, border_flex_child) {
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, border_stretch_child) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetBorder(root, YGEdgeLeft, 10);
YGNodeStyleSetBorder(root, YGEdgeTop, 10);
YGNodeStyleSetBorder(root, YGEdgeRight, 10);
@@ -122,7 +136,7 @@ TEST(YogaTest, border_stretch_child) {
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -150,10 +164,14 @@ TEST(YogaTest, border_stretch_child) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, border_center_child) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetBorder(root, YGEdgeStart, 10);
@@ -162,7 +180,7 @@ TEST(YogaTest, border_center_child) {
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
@@ -191,4 +209,6 @@ TEST(YogaTest, border_center_child) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}

View File

@@ -13,9 +13,11 @@
#include <yoga/Yoga.h>
TEST(YogaTest, wrap_child) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 100);
YGNodeStyleSetHeight(root_child0, 100);
YGNodeInsertChild(root, root_child0, 0);
@@ -44,15 +46,19 @@ TEST(YogaTest, wrap_child) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, wrap_grandchild) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0_child0, 100);
YGNodeStyleSetHeight(root_child0_child0, 100);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
@@ -91,4 +97,6 @@ TEST(YogaTest, wrap_grandchild) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}

View File

@@ -13,16 +13,18 @@
#include <yoga/Yoga.h>
TEST(YogaTest, display_none) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetDisplay(root_child1, YGDisplayNone);
YGNodeInsertChild(root, root_child1, 1);
@@ -61,19 +63,23 @@ TEST(YogaTest, display_none) {
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, display_none_fixed_size) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 20);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeStyleSetDisplay(root_child1, YGDisplayNone);
@@ -113,15 +119,19 @@ TEST(YogaTest, display_none_fixed_size) {
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, display_none_with_margin) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 10);
YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10);
YGNodeStyleSetMargin(root_child0, YGEdgeRight, 10);
@@ -131,7 +141,7 @@ TEST(YogaTest, display_none_with_margin) {
YGNodeStyleSetDisplay(root_child0, YGDisplayNone);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -169,28 +179,32 @@ TEST(YogaTest, display_none_with_margin) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, display_none_with_child) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexShrink(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 0);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetFlexShrink(root_child1, 1);
YGNodeStyleSetFlexBasisPercent(root_child1, 0);
YGNodeStyleSetDisplay(root_child1, YGDisplayNone);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1_child0 = YGNodeNew();
const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1_child0, 1);
YGNodeStyleSetFlexShrink(root_child1_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child1_child0, 0);
@@ -199,7 +213,7 @@ TEST(YogaTest, display_none_with_child) {
YGNodeStyleSetMinHeight(root_child1_child0, 0);
YGNodeInsertChild(root_child1, root_child1_child0, 0);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child2, 1);
YGNodeStyleSetFlexShrink(root_child2, 1);
YGNodeStyleSetFlexBasisPercent(root_child2, 0);
@@ -259,19 +273,23 @@ TEST(YogaTest, display_none_with_child) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, display_none_with_position) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetPosition(root_child1, YGEdgeTop, 10);
YGNodeStyleSetDisplay(root_child1, YGDisplayNone);
@@ -311,4 +329,6 @@ TEST(YogaTest, display_none_with_position) {
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}

View File

@@ -13,18 +13,20 @@
#include <yoga/Yoga.h>
TEST(YogaTest, flex_direction_column_no_height) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -72,22 +74,26 @@ TEST(YogaTest, flex_direction_column_no_height) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, flex_direction_row_no_width) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -135,22 +141,26 @@ TEST(YogaTest, flex_direction_row_no_width) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, flex_direction_column) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -198,23 +208,27 @@ TEST(YogaTest, flex_direction_column) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, flex_direction_row) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -262,23 +276,27 @@ TEST(YogaTest, flex_direction_row) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, flex_direction_column_reverse) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumnReverse);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -326,23 +344,27 @@ TEST(YogaTest, flex_direction_column_reverse) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, flex_direction_row_reverse) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRowReverse);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -390,4 +412,6 @@ TEST(YogaTest, flex_direction_row_reverse) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}

View File

@@ -13,16 +13,18 @@
#include <yoga/Yoga.h>
TEST(YogaTest, flex_basis_flex_grow_column) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasis(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -60,20 +62,24 @@ TEST(YogaTest, flex_basis_flex_grow_column) {
ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, flex_basis_flex_grow_row) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasis(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -111,19 +117,23 @@ TEST(YogaTest, flex_basis_flex_grow_row) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, flex_basis_flex_shrink_column) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexShrink(root_child0, 1);
YGNodeStyleSetFlexBasis(root_child0, 100);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexBasis(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -161,20 +171,24 @@ TEST(YogaTest, flex_basis_flex_shrink_column) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, flex_basis_flex_shrink_row) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexShrink(root_child0, 1);
YGNodeStyleSetFlexBasis(root_child0, 100);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexBasis(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -212,24 +226,28 @@ TEST(YogaTest, flex_basis_flex_shrink_row) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, flex_shrink_to_zero) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root, 75);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexShrink(root_child1, 1);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeStyleSetHeight(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
@@ -278,25 +296,29 @@ TEST(YogaTest, flex_shrink_to_zero) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, flex_basis_overrides_main_size) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasis(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 20);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child2, 1);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
@@ -345,17 +367,21 @@ TEST(YogaTest, flex_basis_overrides_main_size) {
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child2));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, flex_grow_shrink_at_most) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0_child0, 1);
YGNodeStyleSetFlexShrink(root_child0_child0, 1);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
@@ -394,4 +420,6 @@ TEST(YogaTest, flex_grow_shrink_at_most) {
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}

View File

@@ -13,26 +13,28 @@
#include <yoga/Yoga.h>
TEST(YogaTest, wrap_column) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 30);
YGNodeStyleSetHeight(root_child0, 30);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 30);
YGNodeStyleSetHeight(root_child1, 30);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 30);
YGNodeStyleSetHeight(root_child2, 30);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 30);
YGNodeStyleSetHeight(root_child3, 30);
YGNodeInsertChild(root, root_child3, 3);
@@ -91,30 +93,34 @@ TEST(YogaTest, wrap_column) {
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, wrap_row) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 30);
YGNodeStyleSetHeight(root_child0, 30);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 30);
YGNodeStyleSetHeight(root_child1, 30);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 30);
YGNodeStyleSetHeight(root_child2, 30);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 30);
YGNodeStyleSetHeight(root_child3, 30);
YGNodeInsertChild(root, root_child3, 3);
@@ -173,31 +179,35 @@ TEST(YogaTest, wrap_row) {
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, wrap_row_align_items_flex_end) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignItems(root, YGAlignFlexEnd);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 30);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 30);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 30);
YGNodeStyleSetHeight(root_child2, 30);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 30);
YGNodeStyleSetHeight(root_child3, 30);
YGNodeInsertChild(root, root_child3, 3);
@@ -256,31 +266,35 @@ TEST(YogaTest, wrap_row_align_items_flex_end) {
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, wrap_row_align_items_center) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 30);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 30);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 30);
YGNodeStyleSetHeight(root_child2, 30);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 30);
YGNodeStyleSetHeight(root_child3, 30);
YGNodeInsertChild(root, root_child3, 3);
@@ -339,21 +353,25 @@ TEST(YogaTest, wrap_row_align_items_center) {
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, flex_wrap_children_with_min_main_overriding_flex_basis) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexBasis(root_child0, 50);
YGNodeStyleSetMinWidth(root_child0, 55);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexBasis(root_child1, 50);
YGNodeStyleSetMinWidth(root_child1, 55);
YGNodeStyleSetHeight(root_child1, 50);
@@ -393,27 +411,31 @@ TEST(YogaTest, flex_wrap_children_with_min_main_overriding_flex_basis) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, flex_wrap_wrap_to_child_height) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
YGNodeStyleSetAlignItems(root_child0, YGAlignFlexStart);
YGNodeStyleSetFlexWrap(root_child0, YGWrapWrap);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0_child0, 100);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
const YGNodeRef root_child0_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0_child0_child0, 100);
YGNodeStyleSetHeight(root_child0_child0_child0, 100);
YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 100);
YGNodeStyleSetHeight(root_child1, 100);
YGNodeInsertChild(root, root_child1, 1);
@@ -472,20 +494,24 @@ TEST(YogaTest, flex_wrap_wrap_to_child_height) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, flex_wrap_align_stretch_fits_one_row) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 150);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -523,35 +549,39 @@ TEST(YogaTest, flex_wrap_align_stretch_fits_one_row) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, wrap_reverse_row_align_content_flex_start) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetFlexWrap(root, YGWrapWrapReverse);
YGNodeStyleSetWidth(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 30);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 30);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 30);
YGNodeStyleSetHeight(root_child2, 30);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 30);
YGNodeStyleSetHeight(root_child3, 40);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 30);
YGNodeStyleSetHeight(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
@@ -620,36 +650,40 @@ TEST(YogaTest, wrap_reverse_row_align_content_flex_start) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, wrap_reverse_row_align_content_center) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignCenter);
YGNodeStyleSetFlexWrap(root, YGWrapWrapReverse);
YGNodeStyleSetWidth(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 30);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 30);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 30);
YGNodeStyleSetHeight(root_child2, 30);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 30);
YGNodeStyleSetHeight(root_child3, 40);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 30);
YGNodeStyleSetHeight(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
@@ -718,35 +752,39 @@ TEST(YogaTest, wrap_reverse_row_align_content_center) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, wrap_reverse_row_single_line_different_size) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetFlexWrap(root, YGWrapWrapReverse);
YGNodeStyleSetWidth(root, 300);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 30);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 30);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 30);
YGNodeStyleSetHeight(root_child2, 30);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 30);
YGNodeStyleSetHeight(root_child3, 40);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 30);
YGNodeStyleSetHeight(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
@@ -815,36 +853,40 @@ TEST(YogaTest, wrap_reverse_row_single_line_different_size) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, wrap_reverse_row_align_content_stretch) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
YGNodeStyleSetFlexWrap(root, YGWrapWrapReverse);
YGNodeStyleSetWidth(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 30);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 30);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 30);
YGNodeStyleSetHeight(root_child2, 30);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 30);
YGNodeStyleSetHeight(root_child3, 40);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 30);
YGNodeStyleSetHeight(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
@@ -913,36 +955,40 @@ TEST(YogaTest, wrap_reverse_row_align_content_stretch) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, wrap_reverse_row_align_content_space_around) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignContent(root, YGAlignSpaceAround);
YGNodeStyleSetFlexWrap(root, YGWrapWrapReverse);
YGNodeStyleSetWidth(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 30);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 30);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 30);
YGNodeStyleSetHeight(root_child2, 30);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 30);
YGNodeStyleSetHeight(root_child3, 40);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 30);
YGNodeStyleSetHeight(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
@@ -1011,36 +1057,40 @@ TEST(YogaTest, wrap_reverse_row_align_content_space_around) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, wrap_reverse_column_fixed_size) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetFlexWrap(root, YGWrapWrapReverse);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 30);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 30);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 30);
YGNodeStyleSetHeight(root_child2, 30);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child3, 30);
YGNodeStyleSetHeight(root_child3, 40);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child4, 30);
YGNodeStyleSetHeight(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
@@ -1109,25 +1159,29 @@ TEST(YogaTest, wrap_reverse_column_fixed_size) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, wrapped_row_within_align_items_center) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
YGNodeStyleSetFlexWrap(root_child0, YGWrapWrap);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0_child0, 150);
YGNodeStyleSetHeight(root_child0_child0, 80);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
const YGNodeRef root_child0_child1 = YGNodeNew();
const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0_child1, 80);
YGNodeStyleSetHeight(root_child0_child1, 80);
YGNodeInsertChild(root_child0, root_child0_child1, 1);
@@ -1176,25 +1230,29 @@ TEST(YogaTest, wrapped_row_within_align_items_center) {
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, wrapped_row_within_align_items_flex_start) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
YGNodeStyleSetFlexWrap(root_child0, YGWrapWrap);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0_child0, 150);
YGNodeStyleSetHeight(root_child0_child0, 80);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
const YGNodeRef root_child0_child1 = YGNodeNew();
const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0_child1, 80);
YGNodeStyleSetHeight(root_child0_child1, 80);
YGNodeInsertChild(root_child0, root_child0_child1, 1);
@@ -1243,25 +1301,29 @@ TEST(YogaTest, wrapped_row_within_align_items_flex_start) {
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, wrapped_row_within_align_items_flex_end) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignItems(root, YGAlignFlexEnd);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
YGNodeStyleSetFlexWrap(root_child0, YGWrapWrap);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0_child0, 150);
YGNodeStyleSetHeight(root_child0_child0, 80);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
const YGNodeRef root_child0_child1 = YGNodeNew();
const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0_child1, 80);
YGNodeStyleSetHeight(root_child0_child1, 80);
YGNodeInsertChild(root_child0, root_child0_child1, 1);
@@ -1310,4 +1372,6 @@ TEST(YogaTest, wrapped_row_within_align_items_flex_end) {
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}

View File

@@ -13,20 +13,22 @@
#include <yoga/Yoga.h>
TEST(YogaTest, justify_content_row_flex_start) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 102);
YGNodeStyleSetHeight(root, 102);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -74,24 +76,28 @@ TEST(YogaTest, justify_content_row_flex_start) {
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, justify_content_row_flex_end) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd);
YGNodeStyleSetWidth(root, 102);
YGNodeStyleSetHeight(root, 102);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -139,24 +145,28 @@ TEST(YogaTest, justify_content_row_flex_end) {
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, justify_content_row_center) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
YGNodeStyleSetWidth(root, 102);
YGNodeStyleSetHeight(root, 102);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -204,24 +214,28 @@ TEST(YogaTest, justify_content_row_center) {
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, justify_content_row_space_between) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetJustifyContent(root, YGJustifySpaceBetween);
YGNodeStyleSetWidth(root, 102);
YGNodeStyleSetHeight(root, 102);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -269,24 +283,28 @@ TEST(YogaTest, justify_content_row_space_between) {
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, justify_content_row_space_around) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetJustifyContent(root, YGJustifySpaceAround);
YGNodeStyleSetWidth(root, 102);
YGNodeStyleSetHeight(root, 102);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -334,21 +352,25 @@ TEST(YogaTest, justify_content_row_space_around) {
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, justify_content_column_flex_start) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 102);
YGNodeStyleSetHeight(root, 102);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -396,23 +418,27 @@ TEST(YogaTest, justify_content_column_flex_start) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, justify_content_column_flex_end) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd);
YGNodeStyleSetWidth(root, 102);
YGNodeStyleSetHeight(root, 102);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -460,23 +486,27 @@ TEST(YogaTest, justify_content_column_flex_end) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, justify_content_column_center) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
YGNodeStyleSetWidth(root, 102);
YGNodeStyleSetHeight(root, 102);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -524,23 +554,27 @@ TEST(YogaTest, justify_content_column_center) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, justify_content_column_space_between) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetJustifyContent(root, YGJustifySpaceBetween);
YGNodeStyleSetWidth(root, 102);
YGNodeStyleSetHeight(root, 102);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -588,23 +622,27 @@ TEST(YogaTest, justify_content_column_space_between) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, justify_content_column_space_around) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetJustifyContent(root, YGJustifySpaceAround);
YGNodeStyleSetWidth(root, 102);
YGNodeStyleSetHeight(root, 102);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -652,4 +690,6 @@ TEST(YogaTest, justify_content_column_space_around) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}

View File

@@ -13,12 +13,14 @@
#include <yoga/Yoga.h>
TEST(YogaTest, margin_start) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetMargin(root_child0, YGEdgeStart, 10);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
@@ -47,14 +49,18 @@ TEST(YogaTest, margin_start) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, margin_top) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
@@ -83,16 +89,20 @@ TEST(YogaTest, margin_top) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, margin_end) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetMargin(root_child0, YGEdgeEnd, 10);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
@@ -121,15 +131,19 @@ TEST(YogaTest, margin_end) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, margin_bottom) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
@@ -158,15 +172,19 @@ TEST(YogaTest, margin_bottom) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, margin_and_flex_row) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetMargin(root_child0, YGEdgeStart, 10);
YGNodeStyleSetMargin(root_child0, YGEdgeEnd, 10);
@@ -196,14 +214,18 @@ TEST(YogaTest, margin_and_flex_row) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, margin_and_flex_column) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10);
YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 10);
@@ -233,15 +255,19 @@ TEST(YogaTest, margin_and_flex_column) {
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, margin_and_stretch_row) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10);
YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 10);
@@ -271,14 +297,18 @@ TEST(YogaTest, margin_and_stretch_row) {
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, margin_and_stretch_column) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetMargin(root_child0, YGEdgeStart, 10);
YGNodeStyleSetMargin(root_child0, YGEdgeEnd, 10);
@@ -308,20 +338,24 @@ TEST(YogaTest, margin_and_stretch_column) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, margin_with_sibling_row) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetMargin(root_child0, YGEdgeEnd, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -359,19 +393,23 @@ TEST(YogaTest, margin_with_sibling_row) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, margin_with_sibling_column) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -409,21 +447,25 @@ TEST(YogaTest, margin_with_sibling_column) {
ASSERT_FLOAT_EQ(45, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, margin_auto_bottom) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetMarginAuto(root_child0, YGEdgeBottom);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
@@ -462,21 +504,25 @@ TEST(YogaTest, margin_auto_bottom) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, margin_auto_top) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetMarginAuto(root_child0, YGEdgeTop);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
@@ -515,22 +561,26 @@ TEST(YogaTest, margin_auto_top) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, margin_auto_bottom_and_top) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetMarginAuto(root_child0, YGEdgeTop);
YGNodeStyleSetMarginAuto(root_child0, YGEdgeBottom);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
@@ -569,22 +619,26 @@ TEST(YogaTest, margin_auto_bottom_and_top) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, margin_auto_bottom_and_top_justify_center) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetMarginAuto(root_child0, YGEdgeTop);
YGNodeStyleSetMarginAuto(root_child0, YGEdgeBottom);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
@@ -623,27 +677,31 @@ TEST(YogaTest, margin_auto_bottom_and_top_justify_center) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, margin_auto_mutiple_children_column) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetMarginAuto(root_child0, YGEdgeTop);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetMarginAuto(root_child1, YGEdgeTop);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeStyleSetHeight(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
@@ -692,28 +750,32 @@ TEST(YogaTest, margin_auto_mutiple_children_column) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, margin_auto_mutiple_children_row) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetMarginAuto(root_child0, YGEdgeRight);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetMarginAuto(root_child1, YGEdgeRight);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeStyleSetHeight(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
@@ -762,23 +824,27 @@ TEST(YogaTest, margin_auto_mutiple_children_row) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, margin_auto_left_and_right_column) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetMarginAuto(root_child0, YGEdgeLeft);
YGNodeStyleSetMarginAuto(root_child0, YGEdgeRight);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
@@ -817,21 +883,25 @@ TEST(YogaTest, margin_auto_left_and_right_column) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, margin_auto_left_and_right) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetMarginAuto(root_child0, YGEdgeLeft);
YGNodeStyleSetMarginAuto(root_child0, YGEdgeRight);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
@@ -870,6 +940,8 @@ TEST(YogaTest, margin_auto_left_and_right) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, margin_auto_start_and_end_column) {
@@ -981,19 +1053,21 @@ TEST(YogaTest, margin_auto_start_and_end) {
}
TEST(YogaTest, margin_auto_left_and_right_column_and_center) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetMarginAuto(root_child0, YGEdgeLeft);
YGNodeStyleSetMarginAuto(root_child0, YGEdgeRight);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
@@ -1032,21 +1106,25 @@ TEST(YogaTest, margin_auto_left_and_right_column_and_center) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, margin_auto_left) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetMarginAuto(root_child0, YGEdgeLeft);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
@@ -1085,21 +1163,25 @@ TEST(YogaTest, margin_auto_left) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, margin_auto_right) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetMarginAuto(root_child0, YGEdgeRight);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
@@ -1138,22 +1220,26 @@ TEST(YogaTest, margin_auto_right) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, margin_auto_left_and_right_strech) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetMarginAuto(root_child0, YGEdgeLeft);
YGNodeStyleSetMarginAuto(root_child0, YGEdgeRight);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
@@ -1192,21 +1278,25 @@ TEST(YogaTest, margin_auto_left_and_right_strech) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, margin_auto_top_and_bottom_strech) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetMarginAuto(root_child0, YGEdgeTop);
YGNodeStyleSetMarginAuto(root_child0, YGEdgeBottom);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
@@ -1245,4 +1335,6 @@ TEST(YogaTest, margin_auto_top_and_bottom_strech) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}

View File

@@ -13,11 +13,13 @@
#include <yoga/Yoga.h>
TEST(YogaTest, max_width) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetMaxWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
@@ -46,15 +48,19 @@ TEST(YogaTest, max_width) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, max_height) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetMaxHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
@@ -83,19 +89,23 @@ TEST(YogaTest, max_height) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, min_height) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetMinHeight(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -133,20 +143,24 @@ TEST(YogaTest, min_height) {
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, min_width) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetMinWidth(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -184,16 +198,20 @@ TEST(YogaTest, min_width) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, justify_content_min_max) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetMinHeight(root, 100);
YGNodeStyleSetMaxHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 60);
YGNodeStyleSetHeight(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
@@ -222,16 +240,20 @@ TEST(YogaTest, justify_content_min_max) {
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, align_items_min_max) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetMinWidth(root, 100);
YGNodeStyleSetMaxWidth(root, 200);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 60);
YGNodeStyleSetHeight(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
@@ -260,25 +282,29 @@ TEST(YogaTest, align_items_min_max) {
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, justify_content_overflow_min_max) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
YGNodeStyleSetMinHeight(root, 100);
YGNodeStyleSetMaxHeight(root, 110);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 50);
YGNodeStyleSetHeight(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
@@ -327,22 +353,25 @@ TEST(YogaTest, justify_content_overflow_min_max) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, flex_grow_to_min) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureMinFlexFix, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureMinFlexFix, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetMinHeight(root, 100);
YGNodeStyleSetMaxHeight(root, 500);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexShrink(root_child0, 1);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -381,23 +410,24 @@ TEST(YogaTest, flex_grow_to_min) {
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureMinFlexFix, false);
YGConfigFree(config);
}
TEST(YogaTest, flex_grow_in_at_most_container) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureMinFlexFix, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureMinFlexFix, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0_child0, 1);
YGNodeStyleSetFlexBasis(root_child0_child0, 0);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
@@ -437,20 +467,22 @@ TEST(YogaTest, flex_grow_in_at_most_container) {
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureMinFlexFix, false);
YGConfigFree(config);
}
TEST(YogaTest, flex_grow_within_max_width) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
YGNodeStyleSetMaxWidth(root_child0, 100);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0_child0, 1);
YGNodeStyleSetHeight(root_child0_child0, 20);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
@@ -489,19 +521,23 @@ TEST(YogaTest, flex_grow_within_max_width) {
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, flex_grow_within_constrained_max_width) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
YGNodeStyleSetMaxWidth(root_child0, 300);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0_child0, 1);
YGNodeStyleSetHeight(root_child0_child0, 20);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
@@ -540,19 +576,23 @@ TEST(YogaTest, flex_grow_within_constrained_max_width) {
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, flex_grow_within_constrained_min_row) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetMinWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -590,17 +630,21 @@ TEST(YogaTest, flex_grow_within_constrained_min_row) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, flex_grow_within_constrained_min_column) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetMinHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -638,24 +682,28 @@ TEST(YogaTest, flex_grow_within_constrained_min_column) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, flex_grow_within_constrained_max_row) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
YGNodeStyleSetMaxWidth(root_child0, 100);
YGNodeStyleSetHeight(root_child0, 100);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexShrink(root_child0_child0, 1);
YGNodeStyleSetFlexBasis(root_child0_child0, 100);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
const YGNodeRef root_child0_child1 = YGNodeNew();
const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0_child1, 50);
YGNodeInsertChild(root_child0, root_child0_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -703,19 +751,23 @@ TEST(YogaTest, flex_grow_within_constrained_max_row) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, flex_grow_within_constrained_max_column) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetMaxHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexShrink(root_child0, 1);
YGNodeStyleSetFlexBasis(root_child0, 100);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -753,10 +805,14 @@ TEST(YogaTest, flex_grow_within_constrained_max_column) {
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, min_width_overrides_width) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 50);
YGNodeStyleSetMinWidth(root, 100);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -774,10 +830,14 @@ TEST(YogaTest, min_width_overrides_width) {
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, max_width_overrides_width) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetMaxWidth(root, 100);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -795,10 +855,14 @@ TEST(YogaTest, max_width_overrides_width) {
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, min_height_overrides_height) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root, 50);
YGNodeStyleSetMinHeight(root, 100);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -816,10 +880,14 @@ TEST(YogaTest, min_height_overrides_height) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, max_height_overrides_height) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root, 200);
YGNodeStyleSetMaxHeight(root, 100);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -837,15 +905,19 @@ TEST(YogaTest, max_height_overrides_height) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, min_max_percent_no_width_height) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetMinWidthPercent(root_child0, 10);
YGNodeStyleSetMaxWidthPercent(root_child0, 10);
YGNodeStyleSetMinHeightPercent(root_child0, 10);
@@ -876,4 +948,6 @@ TEST(YogaTest, min_max_percent_no_width_height) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}

View File

@@ -13,7 +13,9 @@
#include <yoga/Yoga.h>
TEST(YogaTest, padding_no_size) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetPadding(root, YGEdgeLeft, 10);
YGNodeStyleSetPadding(root, YGEdgeTop, 10);
YGNodeStyleSetPadding(root, YGEdgeRight, 10);
@@ -33,16 +35,20 @@ TEST(YogaTest, padding_no_size) {
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, padding_container_match_child) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetPadding(root, YGEdgeLeft, 10);
YGNodeStyleSetPadding(root, YGEdgeTop, 10);
YGNodeStyleSetPadding(root, YGEdgeRight, 10);
YGNodeStyleSetPadding(root, YGEdgeBottom, 10);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
@@ -71,10 +77,14 @@ TEST(YogaTest, padding_container_match_child) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, padding_flex_child) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetPadding(root, YGEdgeLeft, 10);
YGNodeStyleSetPadding(root, YGEdgeTop, 10);
YGNodeStyleSetPadding(root, YGEdgeRight, 10);
@@ -82,7 +92,7 @@ TEST(YogaTest, padding_flex_child) {
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
@@ -111,10 +121,14 @@ TEST(YogaTest, padding_flex_child) {
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, padding_stretch_child) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetPadding(root, YGEdgeLeft, 10);
YGNodeStyleSetPadding(root, YGEdgeTop, 10);
YGNodeStyleSetPadding(root, YGEdgeRight, 10);
@@ -122,7 +136,7 @@ TEST(YogaTest, padding_stretch_child) {
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -150,10 +164,14 @@ TEST(YogaTest, padding_stretch_child) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, padding_center_child) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetPadding(root, YGEdgeStart, 10);
@@ -162,7 +180,7 @@ TEST(YogaTest, padding_center_child) {
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
@@ -191,16 +209,20 @@ TEST(YogaTest, padding_center_child) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, child_with_padding_align_end) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd);
YGNodeStyleSetAlignItems(root, YGAlignFlexEnd);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 20);
YGNodeStyleSetPadding(root_child0, YGEdgeTop, 20);
YGNodeStyleSetPadding(root_child0, YGEdgeRight, 20);
@@ -233,4 +255,6 @@ TEST(YogaTest, child_with_padding_align_end) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}

View File

@@ -13,14 +13,15 @@
#include <yoga/Yoga.h>
TEST(YogaTest, percentage_width_height) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidthPercent(root_child0, 30);
YGNodeStyleSetHeightPercent(root_child0, 30);
YGNodeInsertChild(root, root_child0, 0);
@@ -50,18 +51,19 @@ TEST(YogaTest, percentage_width_height) {
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGConfigFree(config);
}
TEST(YogaTest, percentage_position_left_top) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 400);
YGNodeStyleSetHeight(root, 400);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionPercent(root_child0, YGEdgeLeft, 10);
YGNodeStyleSetPositionPercent(root_child0, YGEdgeTop, 20);
YGNodeStyleSetWidthPercent(root_child0, 45);
@@ -93,18 +95,19 @@ TEST(YogaTest, percentage_position_left_top) {
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGConfigFree(config);
}
TEST(YogaTest, percentage_position_bottom_right) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 500);
YGNodeStyleSetHeight(root, 500);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionPercent(root_child0, YGEdgeRight, 20);
YGNodeStyleSetPositionPercent(root_child0, YGEdgeBottom, 10);
YGNodeStyleSetWidthPercent(root_child0, 55);
@@ -136,23 +139,24 @@ TEST(YogaTest, percentage_position_bottom_right) {
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGConfigFree(config);
}
TEST(YogaTest, percentage_flex_basis) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetFlexBasisPercent(root_child1, 25);
YGNodeInsertChild(root, root_child1, 1);
@@ -192,22 +196,23 @@ TEST(YogaTest, percentage_flex_basis) {
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGConfigFree(config);
}
TEST(YogaTest, percentage_flex_basis_cross) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetFlexBasisPercent(root_child1, 25);
YGNodeInsertChild(root, root_child1, 1);
@@ -247,22 +252,23 @@ TEST(YogaTest, percentage_flex_basis_cross) {
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGConfigFree(config);
}
TEST(YogaTest, percentage_flex_basis_cross_min_height) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetMinHeightPercent(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 2);
YGNodeStyleSetMinHeightPercent(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
@@ -302,24 +308,25 @@ TEST(YogaTest, percentage_flex_basis_cross_min_height) {
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGConfigFree(config);
}
TEST(YogaTest, percentage_flex_basis_main_max_height) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 10);
YGNodeStyleSetMaxHeightPercent(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 4);
YGNodeStyleSetFlexBasisPercent(root_child1, 10);
YGNodeStyleSetMaxHeightPercent(root_child1, 20);
@@ -360,23 +367,24 @@ TEST(YogaTest, percentage_flex_basis_main_max_height) {
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGConfigFree(config);
}
TEST(YogaTest, percentage_flex_basis_cross_max_height) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 10);
YGNodeStyleSetMaxHeightPercent(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 4);
YGNodeStyleSetFlexBasisPercent(root_child1, 10);
YGNodeStyleSetMaxHeightPercent(root_child1, 20);
@@ -417,24 +425,25 @@ TEST(YogaTest, percentage_flex_basis_cross_max_height) {
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGConfigFree(config);
}
TEST(YogaTest, percentage_flex_basis_main_max_width) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 15);
YGNodeStyleSetMaxWidthPercent(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 4);
YGNodeStyleSetFlexBasisPercent(root_child1, 10);
YGNodeStyleSetMaxWidthPercent(root_child1, 20);
@@ -475,23 +484,24 @@ TEST(YogaTest, percentage_flex_basis_main_max_width) {
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGConfigFree(config);
}
TEST(YogaTest, percentage_flex_basis_cross_max_width) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 10);
YGNodeStyleSetMaxWidthPercent(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 4);
YGNodeStyleSetFlexBasisPercent(root_child1, 15);
YGNodeStyleSetMaxWidthPercent(root_child1, 20);
@@ -532,24 +542,25 @@ TEST(YogaTest, percentage_flex_basis_cross_max_width) {
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGConfigFree(config);
}
TEST(YogaTest, percentage_flex_basis_main_min_width) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 15);
YGNodeStyleSetMinWidthPercent(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 4);
YGNodeStyleSetFlexBasisPercent(root_child1, 10);
YGNodeStyleSetMinWidthPercent(root_child1, 20);
@@ -590,23 +601,24 @@ TEST(YogaTest, percentage_flex_basis_main_min_width) {
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGConfigFree(config);
}
TEST(YogaTest, percentage_flex_basis_cross_min_width) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 10);
YGNodeStyleSetMinWidthPercent(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 4);
YGNodeStyleSetFlexBasisPercent(root_child1, 15);
YGNodeStyleSetMinWidthPercent(root_child1, 20);
@@ -647,17 +659,18 @@ TEST(YogaTest, percentage_flex_basis_cross_min_width) {
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGConfigFree(config);
}
TEST(YogaTest, percentage_multiple_nested_with_padding_margin_and_percentage_values) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 10);
YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 5);
@@ -671,7 +684,7 @@ TEST(YogaTest, percentage_multiple_nested_with_padding_margin_and_percentage_val
YGNodeStyleSetMinWidthPercent(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetMargin(root_child0_child0, YGEdgeLeft, 5);
YGNodeStyleSetMargin(root_child0_child0, YGEdgeTop, 5);
YGNodeStyleSetMargin(root_child0_child0, YGEdgeRight, 5);
@@ -683,7 +696,7 @@ TEST(YogaTest, percentage_multiple_nested_with_padding_margin_and_percentage_val
YGNodeStyleSetWidthPercent(root_child0_child0, 50);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
const YGNodeRef root_child0_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetMarginPercent(root_child0_child0_child0, YGEdgeLeft, 5);
YGNodeStyleSetMarginPercent(root_child0_child0_child0, YGEdgeTop, 5);
YGNodeStyleSetMarginPercent(root_child0_child0_child0, YGEdgeRight, 5);
@@ -695,7 +708,7 @@ TEST(YogaTest, percentage_multiple_nested_with_padding_margin_and_percentage_val
YGNodeStyleSetWidthPercent(root_child0_child0_child0, 45);
YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 4);
YGNodeStyleSetFlexBasisPercent(root_child1, 15);
YGNodeStyleSetMinWidthPercent(root_child1, 20);
@@ -756,17 +769,18 @@ TEST(YogaTest, percentage_multiple_nested_with_padding_margin_and_percentage_val
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGConfigFree(config);
}
TEST(YogaTest, percentage_margin_should_calculate_based_only_on_width) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetMarginPercent(root_child0, YGEdgeLeft, 10);
YGNodeStyleSetMarginPercent(root_child0, YGEdgeTop, 10);
@@ -774,7 +788,7 @@ TEST(YogaTest, percentage_margin_should_calculate_based_only_on_width) {
YGNodeStyleSetMarginPercent(root_child0, YGEdgeBottom, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0_child0, 10);
YGNodeStyleSetHeight(root_child0_child0, 10);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
@@ -814,17 +828,18 @@ TEST(YogaTest, percentage_margin_should_calculate_based_only_on_width) {
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGConfigFree(config);
}
TEST(YogaTest, percentage_padding_should_calculate_based_only_on_width) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetPaddingPercent(root_child0, YGEdgeLeft, 10);
YGNodeStyleSetPaddingPercent(root_child0, YGEdgeTop, 10);
@@ -832,7 +847,7 @@ TEST(YogaTest, percentage_padding_should_calculate_based_only_on_width) {
YGNodeStyleSetPaddingPercent(root_child0, YGEdgeBottom, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0_child0, 10);
YGNodeStyleSetHeight(root_child0_child0, 10);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
@@ -872,17 +887,18 @@ TEST(YogaTest, percentage_padding_should_calculate_based_only_on_width) {
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGConfigFree(config);
}
TEST(YogaTest, percentage_absolute_position) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetPositionPercent(root_child0, YGEdgeLeft, 30);
YGNodeStyleSetPositionPercent(root_child0, YGEdgeTop, 10);
@@ -915,13 +931,15 @@ TEST(YogaTest, percentage_absolute_position) {
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGConfigFree(config);
}
TEST(YogaTest, percentage_width_height_undefined_parent_size) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidthPercent(root_child0, 50);
YGNodeStyleSetHeightPercent(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
@@ -950,27 +968,31 @@ TEST(YogaTest, percentage_width_height_undefined_parent_size) {
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, percent_within_flex_grow) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 350);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 100);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1_child0 = YGNodeNew();
const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidthPercent(root_child1_child0, 100);
YGNodeInsertChild(root_child1, root_child1_child0, 0);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child2, 100);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -1028,4 +1050,6 @@ TEST(YogaTest, percent_within_flex_grow) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}

View File

@@ -11,13 +11,14 @@
#include <yoga/Yoga.h>
TEST(YogaTest, dont_cache_computed_flex_basis_between_layouts) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureWebFlexBasis, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetHeightPercent(root, 100);
YGNodeStyleSetWidthPercent(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexBasisPercent(root_child0, 100);
YGNodeInsertChild(root, root_child0, 0);
@@ -28,7 +29,7 @@ TEST(YogaTest, dont_cache_computed_flex_basis_between_layouts) {
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis, false);
YGConfigFree(config);
}
TEST(YogaTest, recalculate_resolvedDimonsion_onchange) {

View File

@@ -31,18 +31,19 @@ static YGSize _measureCeil(YGNodeRef node,
}
TEST(YogaTest, rounding_feature_with_custom_measure_func_floor) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeSetMeasureFunc(root_child0, _measureFloor);
YGNodeInsertChild(root, root_child0, 0);
YGSetPointScaleFactor(0.0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(10.2, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10.2, YGNodeLayoutGetHeight(root_child0));
@@ -52,40 +53,41 @@ TEST(YogaTest, rounding_feature_with_custom_measure_func_floor) {
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGSetPointScaleFactor(2.0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGSetPointScaleFactor(4.0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(10.25, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10.25, YGNodeLayoutGetHeight(root_child0));
YGSetPointScaleFactor(1.0 / 3.0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(9.0, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(9.0, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGSetPointScaleFactor(1.0);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGConfigFree(config);
}
TEST(YogaTest, rounding_feature_with_custom_measure_func_ceil) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeSetMeasureFunc(root_child0, _measureCeil);
YGNodeInsertChild(root, root_child0, 0);
@@ -99,5 +101,5 @@ TEST(YogaTest, rounding_feature_with_custom_measure_func_ceil) {
YGNodeFreeRecursive(root);
YGSetPointScaleFactor(1.0);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGConfigFree(config);
}

View File

@@ -13,22 +13,23 @@
#include <yoga/Yoga.h>
TEST(YogaTest, rounding_flex_basis_flex_grow_row_width_of_100) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child2, 1);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -77,34 +78,35 @@ TEST(YogaTest, rounding_flex_basis_flex_grow_row_width_of_100) {
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGConfigFree(config);
}
TEST(YogaTest, rounding_flex_basis_flex_grow_row_prime_number_width) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 113);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child2, 1);
YGNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child3 = YGNodeNew();
const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child3, 1);
YGNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child4 = YGNodeNew();
const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child4, 1);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -173,27 +175,28 @@ TEST(YogaTest, rounding_flex_basis_flex_grow_row_prime_number_width) {
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGConfigFree(config);
}
TEST(YogaTest, rounding_flex_basis_flex_shrink_row) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 101);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexShrink(root_child0, 1);
YGNodeStyleSetFlexBasis(root_child0, 100);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexBasis(root_child1, 25);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexBasis(root_child2, 25);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -242,28 +245,29 @@ TEST(YogaTest, rounding_flex_basis_flex_shrink_row) {
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGConfigFree(config);
}
TEST(YogaTest, rounding_flex_basis_overrides_main_size) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 113);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasis(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 20);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child2, 1);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
@@ -313,28 +317,29 @@ TEST(YogaTest, rounding_flex_basis_overrides_main_size) {
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGConfigFree(config);
}
TEST(YogaTest, rounding_total_fractial) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 87.4f);
YGNodeStyleSetHeight(root, 113.4f);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 0.7f);
YGNodeStyleSetFlexBasis(root_child0, 50.3f);
YGNodeStyleSetHeight(root_child0, 20.3f);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1.6f);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child2, 1.1f);
YGNodeStyleSetHeight(root_child2, 10.7f);
YGNodeInsertChild(root, root_child2, 2);
@@ -384,42 +389,43 @@ TEST(YogaTest, rounding_total_fractial) {
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGConfigFree(config);
}
TEST(YogaTest, rounding_total_fractial_nested) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 87.4f);
YGNodeStyleSetHeight(root, 113.4f);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 0.7f);
YGNodeStyleSetFlexBasis(root_child0, 50.3f);
YGNodeStyleSetHeight(root_child0, 20.3f);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0_child0, 1);
YGNodeStyleSetFlexBasis(root_child0_child0, 0.3f);
YGNodeStyleSetPosition(root_child0_child0, YGEdgeBottom, 13.3f);
YGNodeStyleSetHeight(root_child0_child0, 9.9f);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
const YGNodeRef root_child0_child1 = YGNodeNew();
const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0_child1, 4);
YGNodeStyleSetFlexBasis(root_child0_child1, 0.3f);
YGNodeStyleSetPosition(root_child0_child1, YGEdgeTop, 13.3f);
YGNodeStyleSetHeight(root_child0_child1, 1.1f);
YGNodeInsertChild(root_child0, root_child0_child1, 1);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1.6f);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child2, 1.1f);
YGNodeStyleSetHeight(root_child2, 10.7f);
YGNodeInsertChild(root, root_child2, 2);
@@ -489,28 +495,29 @@ TEST(YogaTest, rounding_total_fractial_nested) {
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGConfigFree(config);
}
TEST(YogaTest, rounding_fractial_input_1) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 113.4f);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasis(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 20);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child2, 1);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
@@ -560,28 +567,29 @@ TEST(YogaTest, rounding_fractial_input_1) {
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGConfigFree(config);
}
TEST(YogaTest, rounding_fractial_input_2) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 113.6f);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasis(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 20);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child2, 1);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
@@ -631,29 +639,30 @@ TEST(YogaTest, rounding_fractial_input_2) {
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGConfigFree(config);
}
TEST(YogaTest, rounding_fractial_input_3) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetPosition(root, YGEdgeTop, 0.3f);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 113.4f);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasis(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 20);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child2, 1);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
@@ -703,29 +712,30 @@ TEST(YogaTest, rounding_fractial_input_3) {
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGConfigFree(config);
}
TEST(YogaTest, rounding_fractial_input_4) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetPosition(root, YGEdgeTop, 0.7f);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 113.4f);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasis(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 20);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNew();
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child2, 1);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
@@ -775,5 +785,5 @@ TEST(YogaTest, rounding_fractial_input_4) {
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGConfigFree(config);
}

View File

@@ -13,14 +13,16 @@
#include <yoga/Yoga.h>
TEST(YogaTest, nested_overflowing_child) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0_child0, 200);
YGNodeStyleSetHeight(root_child0_child0, 200);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
@@ -59,19 +61,23 @@ TEST(YogaTest, nested_overflowing_child) {
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, nested_overflowing_child_in_constraint_parent) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 100);
YGNodeStyleSetHeight(root_child0, 100);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0_child0, 200);
YGNodeStyleSetHeight(root_child0_child0, 200);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
@@ -110,18 +116,22 @@ TEST(YogaTest, nested_overflowing_child_in_constraint_parent) {
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, parent_wrap_child_size_overflowing_parent) {
const YGNodeRef root = YGNodeNew();
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 100);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0_child0, 100);
YGNodeStyleSetHeight(root_child0_child0, 200);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
@@ -160,4 +170,6 @@ TEST(YogaTest, parent_wrap_child_size_overflowing_parent) {
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}