-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_three_sum.py
More file actions
26 lines (21 loc) · 883 Bytes
/
Copy pathtest_three_sum.py
File metadata and controls
26 lines (21 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import unittest
from typing import List
from parameterized import parameterized
from algorithms.two_pointers.three_sum import three_sum
THREE_SUM_TEST_CASES = [
([-1, 0, 1, 2, -1, -4], [[-1, -1, 2], [-1, 0, 1]]),
([0, 1, 1], []),
([0, 0, 0], [[0, 0, 0]]),
([-1, 0, 1, 2, -1, -1], [[-1, -1, 2], [-1, 0, 1]]),
([-1, 0, 1, 2, -1, -4], [[-1, -1, 2], [-1, 0, 1]]),
([-1, 0, 1, 2, -1, -4, 2], [[-1, -1, 2], [-1, 0, 1], [-4, 2, 2]]),
([-1, -1, 0, 1, 1, 1, 2], [[-1, -1, 2], [-1, 0, 1]]),
([-1, 0, 1, 2, -1, -4, -1, 2, 1], [[-1, -1, 2], [-1, 0, 1], [-4, 2, 2]]),
]
class ThreeSumTestCases(unittest.TestCase):
@parameterized.expand(THREE_SUM_TEST_CASES)
def test_three_sum(self, nums: List[int], expected: List[List[int]]):
actual = three_sum(nums)
self.assertEqual(expected, actual)
if __name__ == "__main__":
unittest.main()