Summary: Changes the unit test comparsion to use ```ASSERT_FLOAT_EQ``` instead of ```ASSERT_EQ``` as they check float values. Closes https://github.com/facebook/css-layout/pull/257 Reviewed By: splhack Differential Revision: D4213809 Pulled By: emilsjolander fbshipit-source-id: a79d310840814f26a122e1a0f6db47383b17d7e2
61 lines
1.8 KiB
C++
61 lines
1.8 KiB
C++
/**
|
|
* Copyright (c) 2014-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
|
|
#include <CSSLayout/CSSLayout.h>
|
|
#include <gtest/gtest.h>
|
|
|
|
TEST(CSSLayoutTest, copy_style_same) {
|
|
const CSSNodeRef node0 = CSSNodeNew();
|
|
const CSSNodeRef node1 = CSSNodeNew();
|
|
ASSERT_FALSE(CSSNodeIsDirty(node0));
|
|
|
|
CSSNodeCopyStyle(node0, node1);
|
|
ASSERT_FALSE(CSSNodeIsDirty(node0));
|
|
|
|
CSSNodeFree(node0);
|
|
CSSNodeFree(node1);
|
|
}
|
|
|
|
TEST(CSSLayoutTest, copy_style_modified) {
|
|
const CSSNodeRef node0 = CSSNodeNew();
|
|
ASSERT_FALSE(CSSNodeIsDirty(node0));
|
|
ASSERT_EQ(CSSFlexDirectionColumn, CSSNodeStyleGetFlexDirection(node0));
|
|
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMaxHeight(node0)));
|
|
|
|
const CSSNodeRef node1 = CSSNodeNew();
|
|
CSSNodeStyleSetFlexDirection(node1, CSSFlexDirectionRow);
|
|
CSSNodeStyleSetMaxHeight(node1, 10);
|
|
|
|
CSSNodeCopyStyle(node0, node1);
|
|
ASSERT_TRUE(CSSNodeIsDirty(node0));
|
|
ASSERT_EQ(CSSFlexDirectionRow, CSSNodeStyleGetFlexDirection(node0));
|
|
ASSERT_FLOAT_EQ(10, CSSNodeStyleGetMaxHeight(node0));
|
|
|
|
CSSNodeFree(node0);
|
|
CSSNodeFree(node1);
|
|
}
|
|
|
|
TEST(CSSLayoutTest, copy_style_modified_same) {
|
|
const CSSNodeRef node0 = CSSNodeNew();
|
|
CSSNodeStyleSetFlexDirection(node0, CSSFlexDirectionRow);
|
|
CSSNodeStyleSetMaxHeight(node0, 10);
|
|
CSSNodeCalculateLayout(node0, CSSUndefined, CSSUndefined, CSSDirectionLTR);
|
|
ASSERT_FALSE(CSSNodeIsDirty(node0));
|
|
|
|
const CSSNodeRef node1 = CSSNodeNew();
|
|
CSSNodeStyleSetFlexDirection(node1, CSSFlexDirectionRow);
|
|
CSSNodeStyleSetMaxHeight(node1, 10);
|
|
|
|
CSSNodeCopyStyle(node0, node1);
|
|
ASSERT_FALSE(CSSNodeIsDirty(node0));
|
|
|
|
CSSNodeFree(node0);
|
|
CSSNodeFree(node1);
|
|
}
|