-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor the test to include parameterized test cases and add dependencies list with required libraries
- Loading branch information
Showing
3 changed files
with
16 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,7 @@ | |
|
||
# Ignore Gradle build output directory | ||
build | ||
**/bin/ | ||
**/bin/ | ||
|
||
# Python virtual environment | ||
solutions-py/dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
parameterized==0.9.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |