From f2ad6a7d3f8d4f38fd79176de728ad50b5f8a00c Mon Sep 17 00:00:00 2001 From: Daniel Thompson Date: Sat, 6 Feb 2021 13:30:30 +0000 Subject: [PATCH] simulator: test: Add Draw565.bounding_box unit tests Signed-off-by: Daniel Thompson --- wasp/boards/simulator/test_unit.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/wasp/boards/simulator/test_unit.py b/wasp/boards/simulator/test_unit.py index 8e62ea3..940edba 100644 --- a/wasp/boards/simulator/test_unit.py +++ b/wasp/boards/simulator/test_unit.py @@ -1,4 +1,5 @@ import draw565 +import fonts import pytest @pytest.fixture @@ -39,3 +40,20 @@ def test_darken(draw): assert draw.darken(0b10000_100010_10010, 0b10001) == 0b00000_000000_00001 assert draw.darken(0b10000_100100_10010, 0b10001) == 0b00000_000010_00001 +def test_font_height(draw): + assert 24 == draw.bounding_box('A')[1] + + draw.set_font(fonts.sans28) + assert 27 == draw.bounding_box(None)[1] + + draw.set_font(fonts.sans36) + assert 36 == draw.bounding_box('0')[1] + +def test_font_width(draw): + for f in (fonts.sans24, fonts.sans28, fonts.sans36): + draw.set_font(f) + + assert 3 == draw.bounding_box('0000')[0] % 4 + + if f.max_ch() >= 90: + assert draw.bounding_box('IIII')[0] < draw.bounding_box('WWWW')[0]