1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
"""
PC-BASIC test_display
unit tests for display features of Session API
(c) 2020--2023 Rob Hagemans
This file is released under the GNU GPL version 3 or later.
"""
import unittest
import os
from pcbasic import Session
from pcbasic.compat import int2byte
from tests.unit.utils import TestCase, run_tests
class DisplayTest(TestCase):
"""Unit tests for display."""
tag = u'display'
def test_pixels(self):
"""Display all characters in default font."""
with Session() as s:
s.execute(b'''
10 KEY OFF: SCREEN 0: WIDTH 80: CLS
20 DEF SEG = &HB800
30 FOR B = 0 TO 255
40 POKE 2*B, B
50 NEXT
RUN
''')
with open(self.model_path('pixels.bin'), 'rb') as model:
model_pix = model.read()
assert bytes(bytearray(_c for _r in s.get_pixels() for _c in _r)) == model_pix
def test_characters(self):
"""Display all characters."""
with Session() as s:
s.execute(b'''
10 KEY OFF: SCREEN 0: WIDTH 80: CLS
20 DEF SEG = &HB800
30 FOR B = 0 TO 255
40 POKE 2*B, B
50 NEXT
RUN
''')
with open(self.model_path('characters.bin'), 'rb') as model:
model_chars = model.read()
assert bytes(bytearray(_c for _r in self.get_text(s) for _c in _r)) == model_chars
if __name__ == '__main__':
run_tests()
|