BareGit
#include <gtest/gtest.h>
#include "block_parser.h"

using namespace macrodown;

TEST(BlockParserTest, SimpleParagraph)
{
    std::string input = "Hello\nWorld";
    auto root = BlockParser::parse(input);
    
    ASSERT_EQ(root->type, BlockType::Document);
    ASSERT_EQ(root->children.size(), 1);
    
    auto* p = root->children[0].get();
    EXPECT_EQ(p->type, BlockType::Paragraph);
    EXPECT_EQ(p->literal_content, "Hello\nWorld");
}

TEST(BlockParserTest, MultipleParagraphs)
{
    std::string input = "Para 1\n\nPara 2";
    auto root = BlockParser::parse(input);
    
    ASSERT_EQ(root->children.size(), 2);
    EXPECT_EQ(root->children[0]->type, BlockType::Paragraph);
    EXPECT_EQ(root->children[1]->type, BlockType::Paragraph);
}

TEST(BlockParserTest, Headers)
{
    std::string input = "# H1\n## H2";
    auto root = BlockParser::parse(input);
    
    ASSERT_EQ(root->children.size(), 2);
    
    auto* h1 = root->children[0].get();
    EXPECT_EQ(h1->type, BlockType::Heading);
    EXPECT_EQ(h1->level, 1);
    EXPECT_EQ(h1->literal_content, "H1");
    
    auto* h2 = root->children[1].get();
    EXPECT_EQ(h2->type, BlockType::Heading);
    EXPECT_EQ(h2->level, 2);
    EXPECT_EQ(h2->literal_content, "H2");
}

TEST(BlockParserTest, BlockQuote)
{
    std::string input = "> Hello\n> World";
    auto root = BlockParser::parse(input);
    
    ASSERT_EQ(root->children.size(), 1);
    auto* quote = root->children[0].get();
    EXPECT_EQ(quote->type, BlockType::Quote);
    
    ASSERT_EQ(quote->children.size(), 1);
    auto* p = quote->children[0].get();
    EXPECT_EQ(p->type, BlockType::Paragraph);
    EXPECT_EQ(p->literal_content, "Hello\nWorld");
}

TEST(BlockParserTest, NestedQuote)
{
    std::string input = "> Level 1\n>> Level 2";
    auto root = BlockParser::parse(input);
    
    ASSERT_EQ(root->children.size(), 1);
    auto* q1 = root->children[0].get();
    EXPECT_EQ(q1->type, BlockType::Quote);
    
    // Structure: Quote -> [Paragraph("Level 1"), Quote -> [Paragraph("Level 2")]]
    
    ASSERT_EQ(q1->children.size(), 2); // P("Level 1") + Quote
    
    EXPECT_EQ(q1->children[0]->type, BlockType::Paragraph);
    EXPECT_EQ(q1->children[0]->literal_content, "Level 1");
    
    EXPECT_EQ(q1->children[1]->type, BlockType::Quote);
    auto* q2 = q1->children[1].get();
    
    ASSERT_EQ(q2->children.size(), 1);
    EXPECT_EQ(q2->children[0]->literal_content, "Level 2");
}