def test_all_negative_case(): """Testing that function returns correct answer with negative only""" assert find_maximal_subarray_sum([-1, -2, -3, -4, -10], 4) == -1
def test_pos_neg_case(): """Testing that returns correct with positive and negative integers""" assert find_maximal_subarray_sum([1, 3, -1, -3, 5, 3, 6, 7], 3) == 16
def test_empty_list_case(): """Testing that function returns 0 if list is empty""" assert find_maximal_subarray_sum([], 3) == 0
def test_negative_case3(): """Testing with k=0""" assert not find_maximal_subarray_sum([1, 2, 3], k=0) != 0
def test_positive_case1(): """Testing that function finds subarray with max sum correctly""" assert find_maximal_subarray_sum([1, 3, -1, -3, 5, 3, 6, 7], k=3) == 16
def test_negative_case1(): """Testing with k > len(num)""" assert not find_maximal_subarray_sum([1, 2, 3], k=4)
def test_negative_case2(): """Check for output data type""" assert not type(find_maximal_subarray_sum([1, 2, 3], k=1)) != int
def test_find_maximal_subarray_sum_empty_list(): assert find_maximal_subarray_sum([], 2) is None
def test_find_maximal_subarray_sum_negative_nums_only(): assert find_maximal_subarray_sum([-1, -2, -5, -50], 3) == -1
def test_find_maximal_subarray_sum_positive_nums_only_3_val(): assert find_maximal_subarray_sum([1, 2, 5, 50], 3) == 57
def test_find_maximal_subarray_sum_positive_nums_only_2_val(): assert find_maximal_subarray_sum([1, 2, 1, 2, 1], 2) == 3
def test_find_maximal_subarray_sum_positive_and_negatives_nums(): assert find_maximal_subarray_sum([2, -1, 2, -5, -50], 3) == 3
def test_subarray_sum(nums: List[int], k: int, expected_result: int): actual_result = find_maximal_subarray_sum(nums, k) assert actual_result == expected_result
def test_sum_of_subarray_longer_than_array(): """Testing that subarray longer than array gives sum of array.""" arr = [1, -12, 5, 78, 0] assert find_maximal_subarray_sum(arr, 7) == sum(arr)
def test_sum_of_long_array(): """Testing that sum of subarray is counted correctly.""" assert find_maximal_subarray_sum([1, 3, -1, -3, 5, 3, 6, 7], 3) == 16
def test_sum_of_empty_array(): """Testing that sum of subarray of empty array gives zero.""" assert find_maximal_subarray_sum([], 3) == 0