Summary: `/*` is the standard throughout open source code. For example, Firefox uses single /*: https://hg.mozilla.org/mozilla-central/file/21d22b2f541258d3d1cf96c7ba5ad73e96e616b5/gfx/ipc/CompositorWidgetVsyncObserver.cpp#l3 In addition, Rust considers `/**` to be a doc comment (similar to Javadoc) and having such a comment at the beginning of the file causes `rustc` to barf. Note that some JavaScript tooling requires `/**`. This is OK since JavaScript files were not covered by the linter in the first place, but it would be good to have that tooling fixed too. Reviewed By: zertosh Differential Revision: D15640366 fbshipit-source-id: b4ed4599071516364d6109720750d6a43304c089
82 lines
2.4 KiB
C++
82 lines
2.4 KiB
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the LICENSE
|
|
* file in the root directory of this source tree.
|
|
*/
|
|
#include <gtest/gtest.h>
|
|
#include <yoga/YGNode.h>
|
|
#include <iostream>
|
|
|
|
TEST(YogaTest, copy_style_same) {
|
|
const YGNodeRef node0 = YGNodeNew();
|
|
const YGNodeRef node1 = YGNodeNew();
|
|
ASSERT_FALSE(node0->isDirty());
|
|
|
|
YGNodeCopyStyle(node0, node1);
|
|
ASSERT_FALSE(node0->isDirty());
|
|
|
|
YGNodeFree(node0);
|
|
YGNodeFree(node1);
|
|
}
|
|
|
|
TEST(YogaTest, copy_style_modified) {
|
|
const YGNodeRef node0 = YGNodeNew();
|
|
ASSERT_FALSE(node0->isDirty());
|
|
ASSERT_EQ(YGFlexDirectionColumn, YGNodeStyleGetFlexDirection(node0));
|
|
ASSERT_FALSE(YGNodeStyleGetMaxHeight(node0).unit != YGUnitUndefined);
|
|
|
|
const YGNodeRef node1 = YGNodeNew();
|
|
YGNodeStyleSetFlexDirection(node1, YGFlexDirectionRow);
|
|
YGNodeStyleSetMaxHeight(node1, 10);
|
|
|
|
YGNodeCopyStyle(node0, node1);
|
|
ASSERT_TRUE(node0->isDirty());
|
|
ASSERT_EQ(YGFlexDirectionRow, YGNodeStyleGetFlexDirection(node0));
|
|
ASSERT_FLOAT_EQ(10, YGNodeStyleGetMaxHeight(node0).value);
|
|
|
|
YGNodeFree(node0);
|
|
YGNodeFree(node1);
|
|
}
|
|
|
|
TEST(YogaTest, copy_style_modified_same) {
|
|
const YGNodeRef node0 = YGNodeNew();
|
|
YGNodeStyleSetFlexDirection(node0, YGFlexDirectionRow);
|
|
YGNodeStyleSetMaxHeight(node0, 10);
|
|
YGNodeCalculateLayout(node0, YGUndefined, YGUndefined, YGDirectionLTR);
|
|
ASSERT_FALSE(node0->isDirty());
|
|
|
|
const YGNodeRef node1 = YGNodeNew();
|
|
YGNodeStyleSetFlexDirection(node1, YGFlexDirectionRow);
|
|
YGNodeStyleSetMaxHeight(node1, 10);
|
|
|
|
YGNodeCopyStyle(node0, node1);
|
|
ASSERT_FALSE(node0->isDirty());
|
|
|
|
YGNodeFree(node0);
|
|
YGNodeFree(node1);
|
|
}
|
|
|
|
TEST(YogaTest, initialise_flexShrink_flexGrow) {
|
|
const YGNodeRef node0 = YGNodeNew();
|
|
YGNodeStyleSetFlexShrink(node0, 1);
|
|
ASSERT_EQ(1, YGNodeStyleGetFlexShrink(node0));
|
|
|
|
YGNodeStyleSetFlexShrink(node0, YGUndefined);
|
|
YGNodeStyleSetFlexGrow(node0, 3);
|
|
ASSERT_EQ(
|
|
0,
|
|
YGNodeStyleGetFlexShrink(
|
|
node0)); // Default value is Zero, if flex shrink is not defined
|
|
ASSERT_EQ(3, YGNodeStyleGetFlexGrow(node0));
|
|
|
|
YGNodeStyleSetFlexGrow(node0, YGUndefined);
|
|
YGNodeStyleSetFlexShrink(node0, 3);
|
|
ASSERT_EQ(
|
|
0,
|
|
YGNodeStyleGetFlexGrow(
|
|
node0)); // Default value is Zero, if flex grow is not defined
|
|
ASSERT_EQ(3, YGNodeStyleGetFlexShrink(node0));
|
|
YGNodeFree(node0);
|
|
}
|