Files
react-native/packages/react-native/ReactCommon/react/renderer/attributedstring/tests/TextAttributesTest.cpp
T
Christoph PurrerandFacebook GitHub Bot 79c42e7259 Use C++17 namespace format (#36983)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36983

Changelog: [Internal]

This updates ReactCommon/react code to use C++17 namespace format which was already used partially in other files

Reviewed By: NickGerleman

Differential Revision: D45121589

fbshipit-source-id: 0be5a7bce75dc9f8cde7856684f730f4d6df9202
2023-04-19 23:41:29 -07:00

38 lines
1.2 KiB
C++

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <gtest/gtest.h>
#include <react/renderer/attributedstring/TextAttributes.h>
#include <react/renderer/attributedstring/conversions.h>
#include <react/renderer/attributedstring/primitives.h>
#include <react/renderer/core/graphicsConversions.h>
namespace facebook::react {
#ifdef ANDROID
TEST(TextAttributesTest, testToDynamic) {
auto textAttributes = TextAttributes{};
textAttributes.foregroundColor = {
colorFromComponents({200 / 255.0, 153 / 255.0, 100 / 255.0, 1.0})};
textAttributes.opacity = 0.5;
textAttributes.fontStyle = FontStyle::Italic;
textAttributes.fontWeight = FontWeight::Thin;
textAttributes.fontVariant = FontVariant::TabularNums;
auto result = toDynamic(textAttributes);
EXPECT_EQ(
result["foregroundColor"], toDynamic(textAttributes.foregroundColor));
EXPECT_EQ(result["opacity"], textAttributes.opacity);
EXPECT_EQ(result["fontStyle"], toString(textAttributes.fontStyle.value()));
EXPECT_EQ(result["fontWeight"], toString(textAttributes.fontWeight.value()));
}
#endif
} // namespace facebook::react