2 * Copyright (c) 2014-present, Facebook, Inc.
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
8 #include <gtest/gtest.h>
11 TEST(YogaTest, pre_order_traversal) {
12 YGNodeRef const root = YGNodeNew();
13 YGNodeRef const root_child0 = YGNodeNew();
14 YGNodeRef const root_child1 = YGNodeNew();
15 YGNodeRef const root_child0_child0 = YGNodeNew();
17 YGNodeSetChildren(root, {root_child0, root_child1});
18 YGNodeInsertChild(root_child0, root_child0_child0, 0);
20 std::vector<YGNodeRef> visited;
21 YGTraversePreOrder(root, [&visited](YGNodeRef node) {
22 visited.push_back(node);
25 const std::vector<YGNodeRef> expected = {
31 ASSERT_EQ(visited, expected);
33 YGNodeFreeRecursive(root);