from __future__ import annotations from mcp_macro.cot import classify_extreme, compute_percentile def test_compute_percentile_basic(): history = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100] assert compute_percentile(50, history) == 50.0 assert compute_percentile(10, history) == 10.0 assert compute_percentile(100, history) == 100.0 def test_compute_percentile_value_below_min(): history = [10, 20, 30] assert compute_percentile(5, history) == 0.0 def test_compute_percentile_value_above_max(): history = [10, 20, 30] assert compute_percentile(40, history) == 100.0 def test_compute_percentile_empty_history(): assert compute_percentile(50, []) is None def test_classify_extreme_below_threshold(): assert classify_extreme(3.0) == "extreme_short" assert classify_extreme(5.0) == "extreme_short" # boundary inclusive def test_classify_extreme_above_threshold(): assert classify_extreme(96.0) == "extreme_long" assert classify_extreme(95.0) == "extreme_long" # boundary inclusive def test_classify_extreme_neutral(): assert classify_extreme(50.0) == "neutral" assert classify_extreme(94.99) == "neutral" assert classify_extreme(5.01) == "neutral" def test_classify_extreme_none_input(): assert classify_extreme(None) == "neutral"