From fc9eff2da51afd3812bf586edba33e4ae7ae58a7 Mon Sep 17 00:00:00 2001 From: Alex-Gilbert Date: Sun, 15 Feb 2026 22:26:20 -0600 Subject: [PATCH] test: add round-trip integration test for solver Measures a known word's width in font context, then verifies the solver recovers that word from its width. Proves the width table and solver work correctly end-to-end. Co-Authored-By: Claude Opus 4.6 --- tests/test_solver.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/test_solver.py b/tests/test_solver.py index a9b6986..616ca9f 100644 --- a/tests/test_solver.py +++ b/tests/test_solver.py @@ -159,3 +159,25 @@ class TestSolveGapParallel: on_progress=lambda checked, found: progress.append((checked, found)), ) assert len(progress) > 0 + + +class TestRoundTrip: + def test_known_word_found_with_real_font(self): + """Measure a word, then solve for it — the word should appear in results.""" + font = _get_test_font() + word = "Smith" + # Measure "Smith" when preceded by "o" (left context) + target = font.getlength("o" + word) - font.getlength("o") + + results = solve_gap( + font=font, + charset="abcdefghijklmnopqrstuvwxyzST", # include needed uppercase + target_width=target, + tolerance=0.5, + min_length=5, + max_length=5, + left_context="o", + right_context="", + ) + texts = [r.text for r in results] + assert "Smith" in texts