[Yoga] update unit tests
- all unit tests passed
This commit is contained in:
@@ -251,7 +251,7 @@ TEST_F(EventTest, layout_events_has_max_measure_cache) {
|
||||
TEST_F(EventTest, measure_functions_get_wrapped) {
|
||||
auto root = YGNodeNew();
|
||||
YGNodeSetMeasureFunc(
|
||||
root, [](YGNodeRef, float, YGMeasureMode, float, YGMeasureMode) {
|
||||
root, [](YGNodeRef, YGFloat, YGMeasureMode, YGFloat, YGMeasureMode) {
|
||||
return YGSize{};
|
||||
});
|
||||
|
||||
@@ -269,7 +269,7 @@ TEST_F(EventTest, baseline_functions_get_wrapped) {
|
||||
auto child = YGNodeNew();
|
||||
YGNodeInsertChild(root, child, 0);
|
||||
|
||||
YGNodeSetBaselineFunc(child, [](YGNodeRef, float, float) { return 0.0f; });
|
||||
YGNodeSetBaselineFunc(child, [](YGNodeRef, YGFloat, YGFloat) { return 0.0; });
|
||||
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
|
||||
YGNodeStyleSetAlignItems(root, YGAlignBaseline);
|
||||
|
||||
|
@@ -9,18 +9,18 @@
|
||||
#include <yoga/YGNode.h>
|
||||
#include <yoga/Yoga.h>
|
||||
|
||||
static float _baselineFunc(
|
||||
static YGFloat _baselineFunc(
|
||||
YGNodeRef node,
|
||||
const float width,
|
||||
const float height) {
|
||||
const YGFloat width,
|
||||
const YGFloat height) {
|
||||
return height / 2;
|
||||
}
|
||||
|
||||
static YGSize _measure1(
|
||||
YGNodeRef node,
|
||||
float width,
|
||||
YGFloat width,
|
||||
YGMeasureMode widthMode,
|
||||
float height,
|
||||
YGFloat height,
|
||||
YGMeasureMode heightMode) {
|
||||
return YGSize{
|
||||
.width = 42,
|
||||
@@ -30,9 +30,9 @@ static YGSize _measure1(
|
||||
|
||||
static YGSize _measure2(
|
||||
YGNodeRef node,
|
||||
float width,
|
||||
YGFloat width,
|
||||
YGMeasureMode widthMode,
|
||||
float height,
|
||||
YGFloat height,
|
||||
YGMeasureMode heightMode) {
|
||||
return YGSize{
|
||||
.width = 279,
|
||||
|
@@ -11,9 +11,9 @@
|
||||
|
||||
static YGSize _measure(
|
||||
YGNodeRef node,
|
||||
float width,
|
||||
YGFloat width,
|
||||
YGMeasureMode widthMode,
|
||||
float height,
|
||||
YGFloat height,
|
||||
YGMeasureMode heightMode) {
|
||||
return YGSize{
|
||||
.width = widthMode == YGMeasureModeExactly ? width : 50,
|
||||
|
@@ -9,8 +9,8 @@
|
||||
#include <yoga/YGNode.h>
|
||||
#include <yoga/Yoga.h>
|
||||
|
||||
static float _baseline(YGNodeRef node, const float width, const float height) {
|
||||
float* baseline = (float*) node->getContext();
|
||||
static YGFloat _baseline(YGNodeRef node, const YGFloat width, const YGFloat height) {
|
||||
YGFloat* baseline = (YGFloat*) node->getContext();
|
||||
return *baseline;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ TEST(YogaTest, align_baseline_customer_func) {
|
||||
YGNodeStyleSetHeight(root_child1, 20);
|
||||
YGNodeInsertChild(root, root_child1, 1);
|
||||
|
||||
float baselineValue = 10;
|
||||
YGFloat baselineValue = 10;
|
||||
const YGNodeRef root_child1_child0 = YGNodeNew();
|
||||
root_child1_child0->setContext(&baselineValue);
|
||||
YGNodeStyleSetWidth(root_child1_child0, 50);
|
||||
|
@@ -11,9 +11,9 @@
|
||||
|
||||
static YGSize _measureMax(
|
||||
YGNodeRef node,
|
||||
float width,
|
||||
YGFloat width,
|
||||
YGMeasureMode widthMode,
|
||||
float height,
|
||||
YGFloat height,
|
||||
YGMeasureMode heightMode) {
|
||||
int* measureCount = (int*) node->getContext();
|
||||
(*measureCount)++;
|
||||
@@ -26,9 +26,9 @@ static YGSize _measureMax(
|
||||
|
||||
static YGSize _measureMin(
|
||||
YGNodeRef node,
|
||||
float width,
|
||||
YGFloat width,
|
||||
YGMeasureMode widthMode,
|
||||
float height,
|
||||
YGFloat height,
|
||||
YGMeasureMode heightMode) {
|
||||
int* measureCount = (int*) node->getContext();
|
||||
*measureCount = *measureCount + 1;
|
||||
@@ -46,9 +46,9 @@ static YGSize _measureMin(
|
||||
|
||||
static YGSize _measure_84_49(
|
||||
YGNodeRef node,
|
||||
float width,
|
||||
YGFloat width,
|
||||
YGMeasureMode widthMode,
|
||||
float height,
|
||||
YGFloat height,
|
||||
YGMeasureMode heightMode) {
|
||||
int* measureCount = (int*) node->getContext();
|
||||
if (measureCount) {
|
||||
|
@@ -10,9 +10,9 @@
|
||||
#include <yoga/Yoga.h>
|
||||
|
||||
struct _MeasureConstraint {
|
||||
float width;
|
||||
YGFloat width;
|
||||
YGMeasureMode widthMode;
|
||||
float height;
|
||||
YGFloat height;
|
||||
YGMeasureMode heightMode;
|
||||
};
|
||||
|
||||
@@ -23,9 +23,9 @@ struct _MeasureConstraintList {
|
||||
|
||||
static YGSize _measure(
|
||||
YGNodeRef node,
|
||||
float width,
|
||||
YGFloat width,
|
||||
YGMeasureMode widthMode,
|
||||
float height,
|
||||
YGFloat height,
|
||||
YGMeasureMode heightMode) {
|
||||
struct _MeasureConstraintList* constraintList =
|
||||
(struct _MeasureConstraintList*) node->getContext();
|
||||
|
@@ -11,9 +11,9 @@
|
||||
|
||||
static YGSize _measure(
|
||||
YGNodeRef node,
|
||||
float width,
|
||||
YGFloat width,
|
||||
YGMeasureMode widthMode,
|
||||
float height,
|
||||
YGFloat height,
|
||||
YGMeasureMode heightMode) {
|
||||
int* measureCount = (int*) node->getContext();
|
||||
if (measureCount) {
|
||||
@@ -28,9 +28,9 @@ static YGSize _measure(
|
||||
|
||||
static YGSize _simulate_wrapping_text(
|
||||
YGNodeRef node,
|
||||
float width,
|
||||
YGFloat width,
|
||||
YGMeasureMode widthMode,
|
||||
float height,
|
||||
YGFloat height,
|
||||
YGMeasureMode heightMode) {
|
||||
if (widthMode == YGMeasureModeUndefined || width >= 68) {
|
||||
return YGSize{.width = 68, .height = 16};
|
||||
@@ -44,9 +44,9 @@ static YGSize _simulate_wrapping_text(
|
||||
|
||||
static YGSize _measure_assert_negative(
|
||||
YGNodeRef node,
|
||||
float width,
|
||||
YGFloat width,
|
||||
YGMeasureMode widthMode,
|
||||
float height,
|
||||
YGFloat height,
|
||||
YGMeasureMode heightMode) {
|
||||
EXPECT_GE(width, 0);
|
||||
EXPECT_GE(height, 0);
|
||||
@@ -643,9 +643,9 @@ TEST(YogaTest, cant_call_negative_measure_horizontal) {
|
||||
|
||||
static YGSize _measure_90_10(
|
||||
YGNodeRef node,
|
||||
float width,
|
||||
YGFloat width,
|
||||
YGMeasureMode widthMode,
|
||||
float height,
|
||||
YGFloat height,
|
||||
YGMeasureMode heightMode) {
|
||||
|
||||
return YGSize{
|
||||
@@ -656,9 +656,9 @@ static YGSize _measure_90_10(
|
||||
|
||||
static YGSize _measure_100_100(
|
||||
YGNodeRef node,
|
||||
float width,
|
||||
YGFloat width,
|
||||
YGMeasureMode widthMode,
|
||||
float height,
|
||||
YGFloat height,
|
||||
YGMeasureMode heightMode) {
|
||||
|
||||
return YGSize{
|
||||
|
@@ -1298,9 +1298,9 @@ TEST(YogaTest, min_max_percent_no_width_height) {
|
||||
|
||||
static YGSize _measureCk_test_label_shrink_based_on_height(
|
||||
YGNodeRef node,
|
||||
float width,
|
||||
YGFloat width,
|
||||
YGMeasureMode widthMode,
|
||||
float height,
|
||||
YGFloat height,
|
||||
YGMeasureMode heightMode) {
|
||||
|
||||
if (heightMode == YGMeasureModeAtMost) {
|
||||
|
@@ -22,7 +22,7 @@ TEST(YGNode, hasMeasureFunc_initial) {
|
||||
|
||||
TEST(YGNode, hasMeasureFunc_with_measure_fn) {
|
||||
auto n = YGNode{};
|
||||
n.setMeasureFunc([](YGNode*, float, YGMeasureMode, float, YGMeasureMode) {
|
||||
n.setMeasureFunc([](YGNode*, YGFloat, YGMeasureMode, YGFloat, YGMeasureMode) {
|
||||
return YGSize{};
|
||||
});
|
||||
ASSERT_TRUE(n.hasMeasureFunc());
|
||||
@@ -32,7 +32,7 @@ TEST(YGNode, measure_with_measure_fn) {
|
||||
auto n = YGNode{};
|
||||
|
||||
n.setMeasureFunc(
|
||||
[](YGNode*, float w, YGMeasureMode wm, float h, YGMeasureMode hm) {
|
||||
[](YGNode*, YGFloat w, YGMeasureMode wm, YGFloat h, YGMeasureMode hm) {
|
||||
return YGSize{w * wm, h / hm};
|
||||
});
|
||||
|
||||
@@ -44,7 +44,7 @@ TEST(YGNode, measure_with_measure_fn) {
|
||||
TEST(YGNode, measure_with_context_measure_fn) {
|
||||
auto n = YGNode{};
|
||||
n.setMeasureFunc(
|
||||
[](YGNode*, float, YGMeasureMode, float, YGMeasureMode, void* ctx) {
|
||||
[](YGNode*, YGFloat, YGMeasureMode, YGFloat, YGMeasureMode, void* ctx) {
|
||||
return *(YGSize*) ctx;
|
||||
});
|
||||
|
||||
@@ -57,11 +57,11 @@ TEST(YGNode, measure_with_context_measure_fn) {
|
||||
TEST(YGNode, switching_measure_fn_types) {
|
||||
auto n = YGNode{};
|
||||
n.setMeasureFunc(
|
||||
[](YGNode*, float, YGMeasureMode, float, YGMeasureMode, void*) {
|
||||
[](YGNode*, YGFloat, YGMeasureMode, YGFloat, YGMeasureMode, void*) {
|
||||
return YGSize{};
|
||||
});
|
||||
n.setMeasureFunc(
|
||||
[](YGNode*, float w, YGMeasureMode wm, float h, YGMeasureMode hm) {
|
||||
[](YGNode*, YGFloat w, YGMeasureMode wm, YGFloat h, YGMeasureMode hm) {
|
||||
return YGSize{w * wm, h / hm};
|
||||
});
|
||||
|
||||
@@ -72,7 +72,7 @@ TEST(YGNode, switching_measure_fn_types) {
|
||||
|
||||
TEST(YGNode, hasMeasureFunc_after_unset) {
|
||||
auto n = YGNode{};
|
||||
n.setMeasureFunc([](YGNode*, float, YGMeasureMode, float, YGMeasureMode) {
|
||||
n.setMeasureFunc([](YGNode*, YGFloat, YGMeasureMode, YGFloat, YGMeasureMode) {
|
||||
return YGSize{};
|
||||
});
|
||||
|
||||
@@ -83,7 +83,7 @@ TEST(YGNode, hasMeasureFunc_after_unset) {
|
||||
TEST(YGNode, hasMeasureFunc_after_unset_context) {
|
||||
auto n = YGNode{};
|
||||
n.setMeasureFunc(
|
||||
[](YGNode*, float, YGMeasureMode, float, YGMeasureMode, void*) {
|
||||
[](YGNode*, YGFloat, YGMeasureMode, YGFloat, YGMeasureMode, void*) {
|
||||
return YGSize{};
|
||||
});
|
||||
|
||||
@@ -98,20 +98,20 @@ TEST(YGNode, hasBaselineFunc_initial) {
|
||||
|
||||
TEST(YGNode, hasBaselineFunc_with_baseline_fn) {
|
||||
auto n = YGNode{};
|
||||
n.setBaselineFunc([](YGNode*, float, float) { return 0.0f; });
|
||||
n.setBaselineFunc([](YGNode*, YGFloat, YGFloat) { return 0.0; });
|
||||
ASSERT_TRUE(n.hasBaselineFunc());
|
||||
}
|
||||
|
||||
TEST(YGNode, baseline_with_baseline_fn) {
|
||||
auto n = YGNode{};
|
||||
n.setBaselineFunc([](YGNode*, float w, float h) { return w + h; });
|
||||
n.setBaselineFunc([](YGNode*, YGFloat w, YGFloat h) { return w + h; });
|
||||
|
||||
ASSERT_EQ(n.baseline(1.25f, 2.5f, nullptr), 3.75f);
|
||||
}
|
||||
|
||||
TEST(YGNode, baseline_with_context_baseline_fn) {
|
||||
auto n = YGNode{};
|
||||
n.setBaselineFunc([](YGNode*, float w, float h, void* ctx) {
|
||||
n.setBaselineFunc([](YGNode*, YGFloat w, YGFloat h, void* ctx) {
|
||||
return w + h + *(float*) ctx;
|
||||
});
|
||||
|
||||
@@ -121,7 +121,7 @@ TEST(YGNode, baseline_with_context_baseline_fn) {
|
||||
|
||||
TEST(YGNode, hasBaselineFunc_after_unset) {
|
||||
auto n = YGNode{};
|
||||
n.setBaselineFunc([](YGNode*, float, float) { return 0.0f; });
|
||||
n.setBaselineFunc([](YGNode*, YGFloat, YGFloat) { return 0.0; });
|
||||
|
||||
n.setBaselineFunc(nullptr);
|
||||
ASSERT_FALSE(n.hasBaselineFunc());
|
||||
@@ -129,7 +129,7 @@ TEST(YGNode, hasBaselineFunc_after_unset) {
|
||||
|
||||
TEST(YGNode, hasBaselineFunc_after_unset_context) {
|
||||
auto n = YGNode{};
|
||||
n.setBaselineFunc([](YGNode*, float, float, void*) { return 0.0f; });
|
||||
n.setBaselineFunc([](YGNode*, YGFloat, YGFloat, void*) { return 0.0; });
|
||||
|
||||
n.setMeasureFunc(nullptr);
|
||||
ASSERT_FALSE(n.hasMeasureFunc());
|
||||
@@ -137,8 +137,8 @@ TEST(YGNode, hasBaselineFunc_after_unset_context) {
|
||||
|
||||
TEST(YGNode, switching_baseline_fn_types) {
|
||||
auto n = YGNode{};
|
||||
n.setBaselineFunc([](YGNode*, float, float, void*) { return 0.0f; });
|
||||
n.setBaselineFunc([](YGNode*, float, float) { return 1.0f; });
|
||||
n.setBaselineFunc([](YGNode*, YGFloat, YGFloat, void*) { return 0.0; });
|
||||
n.setBaselineFunc([](YGNode*, YGFloat, YGFloat) { return 1.0; });
|
||||
ASSERT_EQ(n.baseline(1, 2, nullptr), 1.0f);
|
||||
}
|
||||
|
||||
|
@@ -1196,9 +1196,9 @@ TEST(YogaTest, percent_absolute_position) {
|
||||
|
||||
static YGSize _measureCk_test_label_shrink_based_on_height(
|
||||
YGNodeRef node,
|
||||
float width,
|
||||
YGFloat width,
|
||||
YGMeasureMode widthMode,
|
||||
float height,
|
||||
YGFloat height,
|
||||
YGMeasureMode heightMode) {
|
||||
|
||||
if (heightMode == YGMeasureModeAtMost) {
|
||||
|
@@ -44,9 +44,9 @@ TEST(YogaTest, rounding_value) {
|
||||
|
||||
static YGSize measureText(
|
||||
YGNodeRef node,
|
||||
float width,
|
||||
YGFloat width,
|
||||
YGMeasureMode widthMode,
|
||||
float height,
|
||||
YGFloat height,
|
||||
YGMeasureMode heightMode) {
|
||||
return (YGSize){.width = 10, .height = 10};
|
||||
}
|
||||
|
@@ -11,9 +11,9 @@
|
||||
|
||||
static YGSize _measureFloor(
|
||||
YGNodeRef node,
|
||||
float width,
|
||||
YGFloat width,
|
||||
YGMeasureMode widthMode,
|
||||
float height,
|
||||
YGFloat height,
|
||||
YGMeasureMode heightMode) {
|
||||
return YGSize{
|
||||
width = 10.2f,
|
||||
@@ -23,9 +23,9 @@ static YGSize _measureFloor(
|
||||
|
||||
static YGSize _measureCeil(
|
||||
YGNodeRef node,
|
||||
float width,
|
||||
YGFloat width,
|
||||
YGMeasureMode widthMode,
|
||||
float height,
|
||||
YGFloat height,
|
||||
YGMeasureMode heightMode) {
|
||||
return YGSize{
|
||||
width = 10.5f,
|
||||
@@ -35,9 +35,9 @@ static YGSize _measureCeil(
|
||||
|
||||
static YGSize _measureFractial(
|
||||
YGNodeRef node,
|
||||
float width,
|
||||
YGFloat width,
|
||||
YGMeasureMode widthMode,
|
||||
float height,
|
||||
YGFloat height,
|
||||
YGMeasureMode heightMode) {
|
||||
return YGSize{
|
||||
width = 0.5f,
|
||||
|
Reference in New Issue
Block a user