From 0befde55eb7f9f837a820bc232dbd94133fd617e Mon Sep 17 00:00:00 2001 From: Edern Deneuville Date: Fri, 11 Sep 2026 14:07:47 +0200 Subject: [PATCH] Test Word equation segmentation --- tests/test_math_format.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/test_math_format.py b/tests/test_math_format.py index f02106f..f885a3b 100644 --- a/tests/test_math_format.py +++ b/tests/test_math_format.py @@ -1,6 +1,6 @@ import pytest -from ai_typewriter.math_format import format_math_text +from ai_typewriter.math_format import format_math_text, split_word_equation_segments def test_plain_mode_keeps_linear_math_literal(): @@ -19,6 +19,18 @@ def test_unicode_mode_converts_common_operators(): assert result == "∫₀¹ f(x) dx ≤ ∑ₖ₌₁ⁿ aₖ" +def test_word_equation_segments_keep_word_unicodemath_syntax(): + segments = split_word_equation_segments(r"On pose z_1 = x + iy. Puis \alpha = 2.") + + assert [(segment.kind, segment.value) for segment in segments] == [ + ("text", "On pose "), + ("equation", "z_1 = x + iy"), + ("text", ". Puis "), + ("equation", r"\alpha = 2"), + ("text", "."), + ] + + def test_invalid_math_text_format_is_rejected(): with pytest.raises(ValueError): format_math_text("x_1", "bad")