/** * Copyright (c) 2015-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #include #include #include using namespace facebook::react; TEST(DebugStringConvertibleTest, handleSimpleNode) { SharedDebugStringConvertibleList empty; auto item = std::make_shared("View", "hello", empty, empty); ASSERT_STREQ(item->getDebugName().c_str(), "View"); ASSERT_STREQ(item->getDebugValue().c_str(), "hello"); ASSERT_STREQ(item->getDebugDescription().c_str(), "\n"); } TEST(DebugStringConvertibleTest, handleSimpleNodeWithProps) { SharedDebugStringConvertibleList empty; SharedDebugStringConvertibleList props = { std::make_shared("x", "1", empty, empty) }; auto item = std::make_shared("View", "hello", props, empty); ASSERT_STREQ(item->getDebugName().c_str(), "View"); ASSERT_STREQ(item->getDebugValue().c_str(), "hello"); ASSERT_STREQ(item->getDebugDescription().c_str(), "\n"); } TEST(DebugStringConvertibleTest, handleSimpleNodeWithChildren) { SharedDebugStringConvertibleList empty; SharedDebugStringConvertibleList children = { std::make_shared("Child", "a", empty, empty) }; auto item = std::make_shared("View", "hello", empty, children); ASSERT_STREQ(item->getDebugName().c_str(), "View"); ASSERT_STREQ(item->getDebugValue().c_str(), "hello"); ASSERT_STREQ(item->getDebugDescription().c_str(), "\n \n\n"); } TEST(DebugStringConvertibleTest, handleNestedNode) { SharedDebugStringConvertibleList empty; SharedDebugStringConvertibleList props = { std::make_shared("x", "1", empty, empty) }; SharedDebugStringConvertibleList children = { std::make_shared("Child", "a", props, empty) }; auto item = std::make_shared("View", "hello", props, children); ASSERT_STREQ(item->getDebugName().c_str(), "View"); ASSERT_STREQ(item->getDebugValue().c_str(), "hello"); ASSERT_STREQ(item->getDebugDescription().c_str(), "\n \n\n"); } TEST(DebugStringConvertibleTest, handleNodeWithComplexProps) { SharedDebugStringConvertibleList empty; SharedDebugStringConvertibleList subProps = { std::make_shared("height", "100", empty, empty), std::make_shared("width", "200", empty, empty) }; SharedDebugStringConvertibleList props = { std::make_shared("x", "1", subProps, empty) }; auto item = std::make_shared("View", "hello", props, empty); ASSERT_STREQ(item->getDebugName().c_str(), "View"); ASSERT_STREQ(item->getDebugValue().c_str(), "hello"); ASSERT_STREQ(item->getDebugDescription().c_str(), "\n"); }