2022-11-03 10:25:01 +00:00
|
|
|
#include "s0015_3sum.hpp"
|
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
TEST(Problem15, Case1) {
|
|
|
|
vector<int> i{-1, 0, 1, 2, -1, -4};
|
|
|
|
vector<vector<int>> o1{{-1, -1, 2}, {-1, 0, 1}};
|
|
|
|
vector<vector<int>> o2{{-1, 0, 1}, {-1, -1, 2}};
|
2022-11-30 10:20:36 +00:00
|
|
|
S0015 solution;
|
|
|
|
EXPECT_TRUE(solution.threeSum1(i) == o1 || solution.threeSum1(i) == o2);
|
|
|
|
EXPECT_TRUE(solution.threeSum2(i) == o1 || solution.threeSum2(i) == o2);
|
2022-11-03 10:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Problem15, Case2) {
|
|
|
|
vector<int> i{0, 1, 1};
|
|
|
|
vector<vector<int>> o{};
|
2022-11-30 10:20:36 +00:00
|
|
|
S0015 solution;
|
|
|
|
EXPECT_EQ(solution.threeSum1(i), o);
|
|
|
|
EXPECT_EQ(solution.threeSum2(i), o);
|
2022-11-03 10:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Problem15, Case3) {
|
|
|
|
vector<int> i{0, 0, 0};
|
|
|
|
vector<vector<int>> o{{0, 0, 0}};
|
2022-11-30 10:20:36 +00:00
|
|
|
S0015 solution;
|
|
|
|
EXPECT_EQ(solution.threeSum1(i), o);
|
|
|
|
EXPECT_EQ(solution.threeSum2(i), o);
|
2022-11-03 10:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Problem15, Case4) {
|
|
|
|
vector<int> i{-1, 0, 1};
|
|
|
|
vector<vector<int>> o{{-1, 0, 1}};
|
2022-11-30 10:20:36 +00:00
|
|
|
S0015 solution;
|
|
|
|
EXPECT_EQ(solution.threeSum1(i), o);
|
|
|
|
EXPECT_EQ(solution.threeSum2(i), o);
|
2022-11-03 10:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Problem15, Case5) {
|
|
|
|
vector<int> i{1, 2, -2, -1};
|
|
|
|
vector<vector<int>> o{};
|
2022-11-30 10:20:36 +00:00
|
|
|
S0015 solution;
|
|
|
|
EXPECT_EQ(solution.threeSum1(i), o);
|
|
|
|
EXPECT_EQ(solution.threeSum2(i), o);
|
2022-11-03 10:25:01 +00:00
|
|
|
}
|