Skip to content

Commit

Permalink
feat: LC-0001: Two Sum (#1)
Browse files Browse the repository at this point in the history
refactor the test to include parameterized test cases and add dependencies list with required libraries
  • Loading branch information
galaumang committed Oct 13, 2023
1 parent 9242330 commit 91ecc19
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@

# Ignore Gradle build output directory
build
**/bin/
**/bin/

# Python virtual environment
solutions-py/dev
1 change: 1 addition & 0 deletions solutions-py/dependencies.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
parameterized==0.9.0
17 changes: 11 additions & 6 deletions solutions-py/src/test/array/test_LC_0001_two_sum.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import unittest

from parameterized import parameterized
from typing import List

from src.main.array.LC_0001_two_sum import TwoSum

class TestTwoSum(unittest.TestCase):
def setUp(self) -> None:
self.object = TwoSum()

def test_two_sum(self):
nums = [2,7,11,15]
target = 9
result = self.object.twoSum(nums, target)
self.assertListEqual(result, [0,1])

@parameterized.expand([
([2,7,11,15], 9, [0,1]),
([3,2,4], 6, [1,2]),
([3,3], 6, [0,1])
])
def tests_two_sum(self, nums: List[int], target: int, expected: List[int]):
self.assertListEqual(expected, self.object.twoSum(nums, target))

if __name__ == '__main__':
unittest.main()

0 comments on commit 91ecc19

Please sign in to comment.