Files
sanguo_moziplus_v2/tests/test_find_max.py
T
cfdaily ac8444bb41
CI / lint (pull_request) Successful in 19s
CI / test (pull_request) Failing after 42s
CI / frontend (pull_request) Successful in 19s
CI / notify-on-failure (pull_request) Successful in 1s
[moz] feat(algorithms): 三种排序算法实现最大值查找
- find_max_linear: 线性扫描 O(n)(原 find_max 重命名+alias兼容)
- find_max_bubble: 冒泡排序 O(n²)
- find_max_quickselect: 快速选择 partition O(n) avg
- 37 个测试(7×3 参数化 + 9 一致性 + 7 原有)
2026-06-22 06:25:22 +08:00

29 lines
673 B
Python

"""find_max 单元测试"""
import pytest
from src.algorithms.find_max_linear import find_max
class TestFindMax:
def test_normal_list(self):
assert find_max([3, 1, 4, 1, 5, 9, 2, 6]) == 9
def test_empty_list(self):
assert find_max([]) is None
def test_single_element(self):
assert find_max([42]) == 42
def test_negative_numbers(self):
assert find_max([-5, -1, -10, -3]) == -1
def test_floats(self):
assert find_max([1.5, 2.7, 0.3, 3.14]) == 3.14
def test_mixed_int_float(self):
assert find_max([1, 2.5, 3, 0.1]) == 3
def test_duplicate_max(self):
assert find_max([7, 7, 7]) == 7