"""Tests para best_central_tendency."""

import math
import sys
import os

sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from best_central_tendency import best_central_tendency


def test_best_central_tendency_normal_ish():
    label, value = best_central_tendency([1, 2, 3, 4, 5], "normal-ish")
    assert label == "mean"
    assert abs(value - 3.0) < 1e-9


def test_best_central_tendency_right_skewed():
    label, value = best_central_tendency([1, 2, 3, 4, 5], "right-skewed")
    assert label == "median"
    assert abs(value - 3.0) < 1e-9


def test_best_central_tendency_left_skewed():
    label, value = best_central_tendency([1, 2, 3, 4, 5], "left-skewed")
    assert label == "median"


def test_best_central_tendency_lognormal_ish():
    label, value = best_central_tendency([1, 2, 4, 8], "lognormal-ish")
    assert label == "geometric_mean"
    assert abs(value - 2 ** 1.5) < 1e-6


def test_best_central_tendency_heavy_tail():
    label, value = best_central_tendency([1, 2, 3, 4, 5, 100], "heavy-tail")
    assert label == "trimmed_mean_5%"
    assert not math.isnan(value)


def test_best_central_tendency_empty():
    label, value = best_central_tendency([], "normal-ish")
    assert math.isnan(value)


def test_best_central_tendency_default():
    label, value = best_central_tendency([1, 2, 3, 4, 5], "other")
    assert label == "median"
