diff --git a/tests/test_math_format.py b/tests/test_math_format.py new file mode 100644 index 0000000..f02106f --- /dev/null +++ b/tests/test_math_format.py @@ -0,0 +1,24 @@ +import pytest + +from ai_typewriter.math_format import format_math_text + + +def test_plain_mode_keeps_linear_math_literal(): + assert format_math_text("z_1 + x^2", "plain") == "z_1 + x^2" + + +def test_unicode_mode_converts_indices_exponents_and_symbols(): + result = format_math_text(r"z_1 + x^2 + x_(i+1) + \alpha + \infty", "unicode") + + assert result == "z₁ + x² + xᵢ₊₁ + α + ∞" + + +def test_unicode_mode_converts_common_operators(): + result = format_math_text(r"\int_0^1 f(x) dx \leq \sum_(k=1)^n a_k", "unicode") + + assert result == "∫₀¹ f(x) dx ≤ ∑ₖ₌₁ⁿ aₖ" + + +def test_invalid_math_text_format_is_rejected(): + with pytest.raises(ValueError): + format_math_text("x_1", "bad")