diff --git a/include/solution/2163.h b/include/solution/2163.h new file mode 100644 index 0000000..c3819c5 --- /dev/null +++ b/include/solution/2163.h @@ -0,0 +1,11 @@ +#ifndef INC_2163_H +#define INC_2163_H +#ifdef __cplusplus +extern "C" +{ +#endif + long long minimumDifference(int *nums, int numsSize); +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/2163.c b/src/2163.c new file mode 100644 index 0000000..2b2bbd5 --- /dev/null +++ b/src/2163.c @@ -0,0 +1,4 @@ +#include +long long minimumDifference(int *nums, int numsSize) +{ +} \ No newline at end of file diff --git a/tests/test_2163.cpp b/tests/test_2163.cpp new file mode 100644 index 0000000..af151ee --- /dev/null +++ b/tests/test_2163.cpp @@ -0,0 +1,26 @@ +#include +#include + +class MinimumDifferenceTest : public ::testing::Test +{ + protected: + void AssertMinimumDifference(std::vector input, long long expected) + { + long long result = minimumDifference(input.data(), static_cast(input.size())); + EXPECT_EQ(result, expected); + } +}; + +// 示例 1 +TEST_F(MinimumDifferenceTest, Example1) +{ + std::vector nums = {3, 1, 2}; + AssertMinimumDifference(nums, -1); +} + +// 示例 2 +TEST_F(MinimumDifferenceTest, Example2) +{ + std::vector nums = {7, 9, 5, 8, 1, 3}; + AssertMinimumDifference(nums, 1); +} \ No newline at end of file