Test Word equation segmentation

This commit is contained in:
Edern Deneuville
2026-09-11 14:07:47 +02:00
parent f0c4f75a0c
commit 0befde55eb
+13 -1
View File
@@ -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")