summaryrefslogtreecommitdiff
path: root/wasp
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2021-02-06 13:30:30 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2021-02-06 13:30:30 (GMT)
commitf2ad6a7d3f8d4f38fd79176de728ad50b5f8a00c (patch)
tree4d2e08fbfce28f94342f7503535c6c8fe1453e2f /wasp
parent28dbc663769069b01d852796b124fcd923ff3c6c (diff)
simulator: test: Add Draw565.bounding_box unit tests
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Diffstat (limited to 'wasp')
-rw-r--r--wasp/boards/simulator/test_unit.py18
1 files changed, 18 insertions, 0 deletions
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]