diff options
| author | Daniel Thompson <daniel@redfelineninja.org.uk> | 2021-07-22 19:03:59 (GMT) |
|---|---|---|
| committer | Daniel Thompson <daniel@redfelineninja.org.uk> | 2021-07-22 19:04:50 (GMT) |
| commit | 0831f79a105329f0dd7cd252b9fcd327415e4f82 (patch) | |
| tree | 7aa811f39ff53dd1ae6702615966d2d137da25ad /wasp/boards/simulator/test_unit.py | |
| parent | 586507753b7ad38b8bfd5ed233929c835a72c878 (diff) | |
draw565: Improve line wrapping
Currently the final word of wrapped text will always appear as a single
word on its own line. Fix this by rearranging the break cases to avoid
searching for the most recent space when we get to the end of the text.
Fixes: #230
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Diffstat (limited to 'wasp/boards/simulator/test_unit.py')
| -rw-r--r-- | wasp/boards/simulator/test_unit.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/wasp/boards/simulator/test_unit.py b/wasp/boards/simulator/test_unit.py index f292c9a..4e52322 100644 --- a/wasp/boards/simulator/test_unit.py +++ b/wasp/boards/simulator/test_unit.py @@ -57,3 +57,16 @@ def test_font_width(draw): if f.max_ch() >= 90: assert draw.bounding_box('IIII')[0] < draw.bounding_box('WWWW')[0] + +@pytest.mark.parametrize("input,expected", ( + ('abc', [0, 3]), + ('one.two', [0, 7]), + ('one two', [0, 7]), + ('one two three', [0, 13]), + ('abcdefghijklmnopqrstuvwxyz', [0, 17, 26]), + ('abcdefghijklm nopqrstuvwxyz', [0, 14, 27]), + ('abcde fghij klmno pqrst uvwxyz', [0, 18, 30]), + +)) +def test_wrap(draw, input, expected): + assert draw.wrap(input, 240) == expected |
