2022-11-21 13:32:04 +00:00
|
|
|
#include "s0035_search_insert_position.hpp"
|
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
TEST(Problem35, Case1) {
|
|
|
|
vector<int> nums{1, 3, 5, 6};
|
|
|
|
int target{5};
|
|
|
|
int o{2};
|
2022-11-24 08:44:36 +00:00
|
|
|
Solution1 solution1;
|
|
|
|
Solution2 solution2;
|
|
|
|
EXPECT_EQ(solution1.searchInsert(nums, target), o);
|
|
|
|
EXPECT_EQ(solution2.searchInsert(nums, target), o);
|
2022-11-21 13:32:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Problem35, Case2) {
|
|
|
|
vector<int> nums{1, 3, 5, 6};
|
|
|
|
int target{2};
|
|
|
|
int o{1};
|
2022-11-24 08:44:36 +00:00
|
|
|
Solution1 solution1;
|
|
|
|
Solution2 solution2;
|
|
|
|
EXPECT_EQ(solution1.searchInsert(nums, target), o);
|
|
|
|
EXPECT_EQ(solution2.searchInsert(nums, target), o);
|
2022-11-21 13:32:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Problem35, Case3) {
|
|
|
|
vector<int> nums{1, 3, 5, 6};
|
|
|
|
int target{7};
|
|
|
|
int o{4};
|
2022-11-24 08:44:36 +00:00
|
|
|
Solution1 solution1;
|
|
|
|
Solution2 solution2;
|
|
|
|
EXPECT_EQ(solution1.searchInsert(nums, target), o);
|
|
|
|
EXPECT_EQ(solution2.searchInsert(nums, target), o);
|
2022-11-21 13:32:04 +00:00
|
|
|
}
|