1668
This commit is contained in:
49
tests/test_1668.cpp
Normal file
49
tests/test_1668.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
// This file is generated by mkfile.py
|
||||
// Date: 2025-12-05
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <solution/1668.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
// 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<char *>(sequence.c_str()), const_cast<char *>(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);
|
||||
}
|
||||
Reference in New Issue
Block a user