2022-03-12 03:04:49 +00:00
|
|
|
#include "s0001_two_sum.hpp"
|
2022-03-08 07:54:17 +00:00
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
TEST(Problem1, Case1) {
|
|
|
|
std::vector<int> input1{ 2, 7, 11, 15 };
|
|
|
|
int input2{ 9 };
|
2022-11-30 10:20:36 +00:00
|
|
|
S0001 solution;
|
2022-03-08 07:54:17 +00:00
|
|
|
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 };
|
2022-11-30 10:20:36 +00:00
|
|
|
S0001 solution;
|
2022-03-08 07:54:17 +00:00
|
|
|
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 };
|
2022-11-30 10:20:36 +00:00
|
|
|
S0001 solution;
|
2022-03-08 07:54:17 +00:00
|
|
|
std::vector<int> result = solution.twoSum(input1, input2);
|
|
|
|
std::vector<int> answer = std::vector<int>{ 0, 1 };
|
|
|
|
EXPECT_EQ(result, answer);
|
|
|
|
}
|