Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/run_test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: simple_calculator unit test
name: simple_calculator, max_subarray_sum, and two_sum unit test

on: [push]

Expand Down Expand Up @@ -28,6 +28,7 @@ jobs:
run: |
coverage run -m pytest tests/tests_1b.py -v -s
coverage run -m pytest tests/tests_1c.py -v -s
coverage run -m pytest tests/tests_1d.py -v -s
- name: Generate Coverage Report
run: |
coverage report -m
2 changes: 1 addition & 1 deletion labs/lab_1/lab_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def two_sum(nums: list[int], target: int) -> list[int]:

num_to_index = {}
for index, num in enumerate(nums):
complement = target + num
complement = target - num
if complement in num_to_index:
return [num_to_index[complement], index]
num_to_index[num] = index
Expand Down
4 changes: 2 additions & 2 deletions tests/tests_1c.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
tests_1b.py
tests_1c.py

This module contains unit tests for the max_subarray_sum function defined in lab_1b.py.
This module contains unit tests for the max_subarray_sum function defined in lab_1c.py.
"""

import pytest
Expand Down
17 changes: 17 additions & 0 deletions tests/tests_1d.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""
tests_1d.py

This module contains unit tests for the two_sum function defined in lab_1d.py.
"""

import pytest
from labs.lab_1.lab_1d import two_sum

def test():
assert two_sum([2, 7, 11, 15], 18) == [1, 2]
assert two_sum([2, 7, 11, 15], 26) == [2, 3]
assert two_sum([2, 7, 11, 15], 22) == [1, 3]


if __name__ == "__main__":
pytest.main()
Loading