leetcode/tests/s0015_3sum.cpp

50 lines
1.2 KiB
C++
Raw Normal View History

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}};
Solution1 solution1;
Solution2 solution2;
EXPECT_TRUE(solution1.threeSum(i) == o1 || solution1.threeSum(i) == o2);
EXPECT_TRUE(solution2.threeSum(i) == o1 || solution2.threeSum(i) == o2);
}
TEST(Problem15, Case2) {
vector<int> i{0, 1, 1};
vector<vector<int>> o{};
Solution1 solution1;
Solution2 solution2;
EXPECT_EQ(solution1.threeSum(i), o);
EXPECT_EQ(solution2.threeSum(i), o);
}
TEST(Problem15, Case3) {
vector<int> i{0, 0, 0};
vector<vector<int>> o{{0, 0, 0}};
Solution1 solution1;
Solution2 solution2;
EXPECT_EQ(solution1.threeSum(i), o);
EXPECT_EQ(solution2.threeSum(i), o);
}
TEST(Problem15, Case4) {
vector<int> i{-1, 0, 1};
vector<vector<int>> o{{-1, 0, 1}};
Solution1 solution1;
Solution2 solution2;
EXPECT_EQ(solution1.threeSum(i), o);
EXPECT_EQ(solution2.threeSum(i), o);
}
TEST(Problem15, Case5) {
vector<int> i{1, 2, -2, -1};
vector<vector<int>> o{};
Solution1 solution1;
Solution2 solution2;
EXPECT_EQ(solution1.threeSum(i), o);
EXPECT_EQ(solution2.threeSum(i), o);
}