mirror of
https://github.com/PR0M3TH3AN/unredact.git
synced 2026-10-27 08:40:29 +00:00
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 <[email protected]>
This commit is contained in:
1 parent
556007f5fb
commit
fc9eff2da5
1 file changed
+22
@@ -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
|
||||
Reference in new issue
Block a user