lowobservable.oec/tests/test_display.py
2019-06-15 22:03:26 -05:00

23 lines
812 B
Python

import unittest
import context
from oec.display import encode_ascii_character, encode_string
class EncodeAsciiCharacterTestCase(unittest.TestCase):
def test_mapped_character(self):
self.assertEqual(encode_ascii_character(ord('a')), 0x80)
def test_unmapped_character(self):
self.assertEqual(encode_ascii_character(ord('^')), 0x00)
def test_out_of_range(self):
self.assertEqual(encode_ascii_character(ord('')), 0x00)
class EncodeStringTestCase(unittest.TestCase):
def test_mapped_characters(self):
self.assertEqual(encode_string('Hello, world!'), bytes.fromhex('a7 84 8b 8b 8e 33 00 96 8e 91 8b 83 19'))
def test_unmapped_characters(self):
self.assertEqual(encode_string('Everything ✓'), bytes.fromhex('a4 95 84 91 98 93 87 88 8d 86 00 18'))