leetcode/tests/s0001_two_sum.cpp
2022-03-12 11:04:49 +08:00

32 lines
822 B
C++

#include "s0001_two_sum.hpp"
#include <gtest/gtest.h>
#include <vector>
TEST(Problem1, Case1) {
std::vector<int> input1{ 2, 7, 11, 15 };
int input2{ 9 };
Solution solution;
std::vector<int> result = solution.twoSum(input1, input2);
std::vector<int> answer = std::vector<int>{ 0, 1 };
EXPECT_EQ(result, answer);
}
TEST(Problem1, Case2) {
std::vector<int> input1{ 3, 2, 4 };
int input2{ 6 };
Solution solution;
std::vector<int> result = solution.twoSum(input1, input2);
std::vector<int> answer = std::vector<int>{ 1, 2 };
EXPECT_EQ(result, answer);
}
TEST(Problem1, Case3) {
std::vector<int> input1{ 3, 3 };
int input2{ 6 };
Solution solution;
std::vector<int> result = solution.twoSum(input1, input2);
std::vector<int> answer = std::vector<int>{ 0, 1 };
EXPECT_EQ(result, answer);
}