leetcode/tests/s0015_3sum.cpp
2022-11-30 18:20:36 +08:00

45 lines
1.1 KiB
C++

#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}};
S0015 solution;
EXPECT_TRUE(solution.threeSum1(i) == o1 || solution.threeSum1(i) == o2);
EXPECT_TRUE(solution.threeSum2(i) == o1 || solution.threeSum2(i) == o2);
}
TEST(Problem15, Case2) {
vector<int> i{0, 1, 1};
vector<vector<int>> o{};
S0015 solution;
EXPECT_EQ(solution.threeSum1(i), o);
EXPECT_EQ(solution.threeSum2(i), o);
}
TEST(Problem15, Case3) {
vector<int> i{0, 0, 0};
vector<vector<int>> o{{0, 0, 0}};
S0015 solution;
EXPECT_EQ(solution.threeSum1(i), o);
EXPECT_EQ(solution.threeSum2(i), o);
}
TEST(Problem15, Case4) {
vector<int> i{-1, 0, 1};
vector<vector<int>> o{{-1, 0, 1}};
S0015 solution;
EXPECT_EQ(solution.threeSum1(i), o);
EXPECT_EQ(solution.threeSum2(i), o);
}
TEST(Problem15, Case5) {
vector<int> i{1, 2, -2, -1};
vector<vector<int>> o{};
S0015 solution;
EXPECT_EQ(solution.threeSum1(i), o);
EXPECT_EQ(solution.threeSum2(i), o);
}