25 lines
676 B
C++
25 lines
676 B
C++
#include <gtest/gtest.h>
|
||
#include <solution/3202.h>
|
||
|
||
class MaximumLengthWithKTest : public ::testing::Test
|
||
{
|
||
protected:
|
||
void AssertMaximumLength(const std::vector<int> &nums, int k, int expected)
|
||
{
|
||
int *arr = const_cast<int *>(nums.data());
|
||
int result = maximumLength(arr, nums.size(), k);
|
||
EXPECT_EQ(result, expected);
|
||
}
|
||
};
|
||
|
||
// 示例 1:nums = [1,2,3,4,5], k = 2 => 输出 5
|
||
TEST_F(MaximumLengthWithKTest, AllIncreasing)
|
||
{
|
||
AssertMaximumLength({1, 2, 3, 4, 5}, 2, 5);
|
||
}
|
||
|
||
// 示例 2:nums = [1,4,2,3,1,4], k = 3 => 输出 4
|
||
TEST_F(MaximumLengthWithKTest, AlternatingValidPairs)
|
||
{
|
||
AssertMaximumLength({1, 4, 2, 3, 1, 4}, 3, 4);
|
||
} |