"""indicators — 순수 수치 검증."""
from indicators import sma, rsi_series, highest_high


def test_sma_basic():
    assert sma([1, 2, 3, 4, 5], 5) == 3.0
    assert sma([1, 2, 3, 4, 5], 2) == 4.5


def test_sma_insufficient():
    assert sma([1, 2], 5) is None
    assert sma([], 3) is None


def test_highest_high():
    assert highest_high([1, 9, 3, 4], 3) == 9
    assert highest_high([1, 2, 3], 3) == 3
    assert highest_high([1, 2], 3) is None


def test_rsi_all_gains_is_100():
    # 단조 증가 → 손실 0 → RSI 100
    closes = [float(i) for i in range(1, 20)]
    rs = rsi_series(closes, 14)
    assert rs, "series should not be empty"
    assert rs[-1] == 100.0


def test_rsi_insufficient():
    assert rsi_series([1, 2, 3], 14) == []


def test_rsi_known_range():
    # 등락 섞인 시계열 → RSI는 0~100 사이
    closes = [10, 11, 10.5, 11.5, 11, 12, 11.8, 12.5, 12, 13,
              12.7, 13.2, 12.9, 13.5, 13.1, 13.8]
    rs = rsi_series(closes, 14)
    assert len(rs) == len(closes) - 14
    assert all(0.0 <= v <= 100.0 for v in rs)
