Test explicit equation markers

This commit is contained in:
Edern Deneuville
2026-09-11 14:28:30 +02:00
parent ea3116e45a
commit c1c2e5fd53
+19 -8
View File
@@ -13,14 +13,8 @@ def test_unicode_mode_converts_indices_exponents_and_symbols():
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_word_equation_segments_keep_word_unicodemath_syntax():
segments = split_word_equation_segments(r"On pose z_1 = x + iy. Puis \alpha = 2.")
def test_marker_mode_only_uses_explicit_equation_blocks():
segments = split_word_equation_segments(r"On pose [EQ]z_1 = x + iy[/EQ]. Puis [EQ]\alpha = 2[/EQ].")
assert [(segment.kind, segment.value) for segment in segments] == [
("text", "On pose "),
@@ -31,6 +25,23 @@ def test_word_equation_segments_keep_word_unicodemath_syntax():
]
def test_marker_mode_does_not_guess_math_without_markers():
segments = split_word_equation_segments(r"z_1 reste du texte normal sans marqueur.")
assert [(segment.kind, segment.value) for segment in segments] == [
("text", r"z_1 reste du texte normal sans marqueur."),
]
def test_unclosed_equation_marker_consumes_the_rest():
segments = split_word_equation_segments(r"Résultat: [EQ]x^2 + 1")
assert [(segment.kind, segment.value) for segment in segments] == [
("text", "Résultat: "),
("equation", "x^2 + 1"),
]
def test_invalid_math_text_format_is_rejected():
with pytest.raises(ValueError):
format_math_text("x_1", "bad")