"""Test untuk fungsi murni hitung() pada Kalkulator Terminal."""

import pytest

from main import hitung


def test_tambah():
    assert hitung(10, "+", 5) == 15


def test_kurang():
    assert hitung(10, "-", 4) == 6


def test_kali():
    assert hitung(6, "*", 7) == 42


def test_bagi():
    assert hitung(10, "/", 4) == 2.5


def test_bagi_dengan_nol():
    with pytest.raises(ZeroDivisionError):
        hitung(5, "/", 0)


def test_operator_tidak_dikenal():
    with pytest.raises(ValueError):
        hitung(5, "%", 2)


def test_bilangan_negatif():
    assert hitung(-4, "+", 9) == 5
    assert hitung(-3, "*", -2) == 6


def test_bilangan_desimal():
    assert hitung(2.5, "*", 4) == 10
    assert hitung(7.5, "-", 0.5) == 7
