// This file is generated by mkfile.py // Date: 2025-12-05 #include #include #include // Tests for maxRepeating (LeetCode 1668) class MaxRepeatingTest : public ::testing::Test { protected: void AssertMaxRepeating(const std::string &sequence, const std::string &word, int expected) { int result = maxRepeating(const_cast(sequence.c_str()), const_cast(word.c_str())); ASSERT_EQ(result, expected); } }; TEST_F(MaxRepeatingTest, Example1) { AssertMaxRepeating("ababc", "ab", 2); } TEST_F(MaxRepeatingTest, Example2) { AssertMaxRepeating("ababc", "ba", 1); } TEST_F(MaxRepeatingTest, RepeatedMany) { AssertMaxRepeating("abababab", "ab", 4); } TEST_F(MaxRepeatingTest, OverlappingNotAllowed) { // word = "aa", repeated twice is "aaaa" which appears, so answer 2 AssertMaxRepeating("aaaaa", "aa", 2); } TEST_F(MaxRepeatingTest, ShorterThanWord) { AssertMaxRepeating("a", "aa", 0); } TEST_F(MaxRepeatingTest, SingleCharWord) { AssertMaxRepeating("aaaa", "a", 4); }