// This file is generated by mkfile.py
// Date: 2026-06-25

#include <gtest/gtest.h>
#include <solution/10.h>

#include <string>
#include <vector>

class RegexMatchTest : public ::testing::Test
{
  protected:
    void AssertIsMatch(const std::string &s, const std::string &p, bool expected)
    {
        std::vector<char> s_buffer(s.begin(), s.end());
        std::vector<char> p_buffer(p.begin(), p.end());
        s_buffer.push_back('\0');
        p_buffer.push_back('\0');

        EXPECT_EQ(isMatch(s_buffer.data(), p_buffer.data()), expected);
    }
};

TEST_F(RegexMatchTest, Example1)
{
    AssertIsMatch("aa", "a", false);
}

TEST_F(RegexMatchTest, Example2)
{
    AssertIsMatch("aa", "a*", true);
}

TEST_F(RegexMatchTest, Example3)
{
    AssertIsMatch("ab", ".*", true);
}

TEST_F(RegexMatchTest, Example4)
{
    AssertIsMatch("aab", "c*a*b", true);
}

TEST_F(RegexMatchTest, Example5)
{
    AssertIsMatch("mississippi", "mis*is*p*.", false);
}

TEST_F(RegexMatchTest, EmptyString)
{
    AssertIsMatch("", "", true);
    AssertIsMatch("", "a*", true);
    AssertIsMatch("", "c*c*", true);
    AssertIsMatch("", ".", false);
}

TEST_F(RegexMatchTest, DotMatchesAnySingleCharacter)
{
    AssertIsMatch("ab", ".b", true);
    AssertIsMatch("ab", "..", true);
    AssertIsMatch("ab", ".", false);
}

TEST_F(RegexMatchTest, StarCanMatchZeroCharacters)
{
    AssertIsMatch("b", "a*b", true);
    AssertIsMatch("ab", "ab*c", false);
    AssertIsMatch("a", "ab*", true);
}

TEST_F(RegexMatchTest, StarCanMatchMultipleCharacters)
{
    AssertIsMatch("aaa", "a*", true);
    AssertIsMatch("aaaaab", "a*b", true);
    AssertIsMatch("bbbba", ".*a*a", true);
}

TEST_F(RegexMatchTest, MustMatchWholeString)
{
    AssertIsMatch("abcd", "d*", false);
    AssertIsMatch("abc", ".*d", false);
    AssertIsMatch("aaa", "aaaa", false);
}

TEST_F(RegexMatchTest, ComplexBacktrackingCases)
{
    AssertIsMatch("aaa", "ab*a*c*a", true);
    AssertIsMatch("a", ".*..a*", false);
    AssertIsMatch("mississippi", "mis*is*ip*.", true);
}
