Skip to content
Merged

e #4

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
Expand Up @@ -26,7 +26,8 @@ jobs:
continue-on-error: true
- name: Test with pytest
run: |
coverage run -m pytest tests/tests_1b.py -v -s
coverage run -m pytest tests/tests_1b.py -v -s
coverage run -m pytest tests/tests_1c.py -v -s
- name: Generate Coverage Report
run: |
coverage report -m
2 changes: 1 addition & 1 deletion labs/lab_1/lab_1c.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def max_subarray_sum(nums: list[int]) -> int:

for num in nums:
max_current = max(num, max_current + num)
if max_current < max_global:
if max_current > max_global:
max_global = max_current

return max_global
Expand Down
17 changes: 17 additions & 0 deletions tests/tests_1c.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""
tests_1b.py

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

import pytest
from labs.lab_1.lab_1c import max_subarray_sum

def test():
assert max_subarray_sum([-2,1,-3,4,-1,2,1,-5,4]) == 6
assert max_subarray_sum([-2,1,-3,4,-1,2,3,-5,4]) == 8
assert max_subarray_sum([-2,1,-3,1,-1,2,1,-5,4]) == 4


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