// This file is generated by mkfile.py
// Date: 2026-03-09

#include <gtest/gtest.h>
#include <solution/222.h>
class CountNodesTest : public ::testing::Test
{
  protected:
    TreeNode *createNode(int val)
    {
        TreeNode *node = new TreeNode;
        node->val = val;
        node->left = nullptr;
        node->right = nullptr;
        return node;
    }

    void freeTree(TreeNode *root)
    {
        if (!root)
            return;
        freeTree(root->left);
        freeTree(root->right);
        delete root;
    }
};

// 示例 1
TEST_F(CountNodesTest, Example1)
{
    // 构建树: [1,2,3,4,5,6]
    TreeNode *root = createNode(1);
    root->left = createNode(2);
    root->right = createNode(3);
    root->left->left = createNode(4);
    root->left->right = createNode(5);
    root->right->left = createNode(6);

    EXPECT_EQ(countNodes(root), 6);

    freeTree(root);
}

// 示例 2
TEST_F(CountNodesTest, Example2)
{
    TreeNode *root = nullptr;
    EXPECT_EQ(countNodes(root), 0);
}

// 示例 3
TEST_F(CountNodesTest, Example3)
{
    TreeNode *root = createNode(1);

    EXPECT_EQ(countNodes(root), 1);

    freeTree(root);
}